• Resolved jerome330

    (@jerome330)


    Hello,

    I’m trying to wrap some javascript in one of my template files using this plugin and a shortcode. Everytime I go to save the page using the below code it causes the page to break and not show any content. Here is the code I’m using below:

    <?php echo do_shortcode(‘[showto browser=”desktop”]
    <div id=”contentclick6964″></div>
    <script type=”text/javascript”>
    (function() {
    var data =
    {
    pub_id: “2818”,w_id: “6964”,pw: “21b55185dff4f8”, cbust: (new Date()).getTime()
    };
    if (typeof widgetCheck6964 === ‘undefined’) {
    var u=””;
    for(var key in data){u+=key+”=”+data[key]+”&”}
    u=u.substring(0,u.length-1);
    var a = document.createElement(“script”);
    a.type= ‘text/javascript’;
    a.src = “https://api.contentclick.co.uk/pub_serve.php?&#8221; + u;
    a.async = true;
    document.getElementById(“contentclick6964”).appendChild(a);
    window.widgetCheck6964 = “set”;
    }
    })();
    </script>
    [/showto]’); ?>

    Could this be conflicting with my javascript ad tag of some sort?

    Thanks in advance for any help you can give me!

    https://wordpress.org/plugins/browser-body-classes-with-shortcodes/

Viewing 10 replies - 16 through 25 (of 25 total)
  • Plugin Author thomstark

    (@thomstark)

    Do they show up in any desktop environment? The plugin defines desktop as anything not mobile/tablet. Is it the same in all browsers?

    Can you give me a link to the page?

    Thread Starter jerome330

    (@jerome330)

    They do show up for the most part and they seem to be working in all the browsers I’ve tested. Sometimes, I get complaints from the company owners that our sites are firing mobile/tablet ads on Desktop. Here is a link to one of our promo pages: http://foreverceleb.com/celebrities-photoshopped-plus-size-david-lopera/4/

    If you click through each page you might see a mobile/tablet ad appear? Anything I could possible code better to assure these fire on the correct device 100%?

    Thanks again for your help and this awesome plugin!

    Plugin Author thomstark

    (@thomstark)

    I’m only seeing desktop ads on fifteen pages I checked. All of them also only have the ‘desktop’ body class added. Are you seeing desktop ads AND mobile or tablet ads on the same page? Or just mobile/tablet ads on a desktop page, but no desktop ads? Because my plugin determines one or the other, it can’t be classified as both desktop and mobile, or both desktop and tablet.

    Now, I suppose you could be getting a false positive, where a desktop is triggering as mobile or tablet, but I would need to see a specific example to figure out why.

    Thread Starter jerome330

    (@jerome330)

    Sometimes I only see just mobile/tablet ads on a desktop page and no desktop ads. However, on my end, It does not happen very often. I’ve also seen desktop ads fire on Tablet devices once in awhile.

    Plugin Author thomstark

    (@thomstark)

    Thanks for the clarification. Again, without a specific example in front of me, there’s not much I can do to troubleshoot.

    As for the opposite scenario (desktop ads showing up on tablets), that’s much easier to explain: my list of tablet devices in my user agent string search is finite. To resolve those cases, I would need the user agent string of the device’s browser where the desktop ad is showing up.

    For desktop ads on tablets/mobiles, you can put this snippet in your functions.php and navigate to the page on the device in question, then send me the output:

    function check_user_agent_for_thom()
    {
        if(current_user_can('administrator'))
        {
            echo 'USER AGENT STRING: '.$_SERVER['HTTP_USER_AGENT'].'<br><br>';
        }
    }
    //check_user_agent_for_thom();

    Then just uncomment the last line whenever you want to activate it, and comment it out to deactivate it.

    Plugin Author thomstark

    (@thomstark)

    I don’t know if this would work, but you also might just try a purely jQuery solution based on window width, e.g.:

    <div id="lm-center-ads">
    <script>
    jQuery(document).ready(function($)
    {
    	if($(window).width() > 800) $.getScript("http://ib.adnxs.com/ttj?id=4566610");
    	else if($(window).width() > 480) $.getScript("http://ib.adnxs.com/ttj?id=4566622");
    	else $.getScript("http://ib.adnxs.com/ttj?id=4566628");
    });
    </script>
    </div>
    Thread Starter jerome330

    (@jerome330)

    I completely understand that you can’t trouble shoot without an example that is showing the mobile/tablet ads on desktop, so no worries there. As long as my code looks right etc I think it could be the adserver we use that is misfiring ads. We have so many that I could easily see how this could happen. If I come across a page and can verify it’s spitting out mobile/table ads on a desktop, I’ll shoot you link. Also, thanks for that possible jQuery solution above. I’m not to familiar with JQuery but I will certainly look in to this. Would I put the tag directly into the double quotes like this:

    if($(window).width() > 800) $.getScript("<!-- BEGIN JS TAG - FC - Desktop - 728x90 - just below article title < - DO NOT MODIFY -->
    <SCRIPT SRC="http://ib.adnxs.com/ttj?id=4566610" TYPE="text/javascript"></SCRIPT>
    <!-- END TAG -->");

    Or would it just be like your example with the direct link within the double quotes?

    Thanks and have a good rest of your weekend.

    Plugin Author thomstark

    (@thomstark)

    Yeah, with the $.getScript() function you have to put the url in the quotes. If the tag itself is required for the ads to work, then this probably won’t work for you, but I’m sure there’s a way to do it in jQuery with a little googling.

    Thread Starter jerome330

    (@jerome330)

    Great, I’ll test this out and see if I can get it to work with our ad tags.

    Thread Starter jerome330

    (@jerome330)

    Hi,

    I’ve seem to found a page on one of my sites that is acting like a mobile device using a desktop computer. I’m not sure if this only happening on my end or not? It looks like I only see the issue within Safari and Firefox. Chrome appears to be working properly.

    http://popwebnews.com/15-celebrity-virgins-who-are-waiting-or-waited-for-marriage/7/

Viewing 10 replies - 16 through 25 (of 25 total)

The topic ‘Javascript within php echo do_shortcode’ is closed to new replies.