Support » Plugin: Ad Inserter - Ad Manager & AdSense Ads » Issue with AMP

  • Resolved godthor

    (@godthor)


    I noticed an interesting issue. I setup two Adsense ads with rotate so I could do some testing.

    <!-- Before H2 w/Native -->
    <ins class="adsbygoogle"
         style="display:block; text-align:center; background-color: #FFF;"
         data-ad-layout="in-article"
         data-ad-format="fluid"
         data-ad-client="ca-pub-8275046480529684"
         data-ad-slot="8912102149"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    |rotate|
    <!-- CT: Before H2 -->
    <ins class="adsbygoogle"
         style="display:block; background-color: #FFF;"
         data-ad-client="ca-pub-8275046480529684"
         data-ad-slot="4733121988"
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

    And that works as intended on normal posts. However, on AMP posts it will throw a 500 error. Of course, that code shouldn’t be getting put into AMP posts anyway since I don’t have the checkbox for AMP checked and I’m not providing the [ADINSERTER AMP] code.

    The only other thing of note is that I’m using W3 Total Cache. I have tested that turning W3 off fixes it, as does using client side for dynamic blocks, but it won’t work with server side using W3.

    I get that it can be problematic with W3, but I figured since I wasn’t trying to insert ads on AMP anyway, that this wouldn’t be such an issue.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Spacetime

    (@spacetime)

    Which AMP plugin are you using?

    The one by Automattic.

    Plugin Author Spacetime

    (@spacetime)

    You are right, this block will not be inserted on AMP pages.

    I’m sorry but I can’t reproduce the issue.
    Can you please check PHP log for that error?

    This is what I’m seeing as a result of the 500 error:

    [Mon Jun 25 13:02:24.388416 2018] [cgi:error] [pid 22154] [client 162.158.63.183:30689] AH01215: PHP Parse error:  syntax error, unexpected ';' in /home/creative/public_html/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(1714) : eval()'d code on line 1: /usr/local/cpanel/cgi-sys/ea-php70
    [Mon Jun 25 12:53:55.850704 2018] [cgi:error] [pid 22186] [client 162.158.63.183:31497] AH01215: PHP Parse error:  syntax error, unexpected ';' in /home/creative/public_html/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(1714) : eval()'d code on line 1: /usr/local/cpanel/cgi-sys/ea-php70

    The code in question from W3 is this:

    		if ( $code ) {
    			$code = trim( $code, ';' ) . ';';
    
    			try {
    				ob_start();
    				$result = eval( $code );
    				$output = ob_get_contents();
    				ob_end_clean();
    			}
    

    Specifically the eval line. So, I’m guessing there’s something Ad Inserter is doing in this situation that W3 is having a fit about regarding the semi-colon.

    Plugin Author Spacetime

    (@spacetime)

    I see.

    This is a bug of the AMP plugin that was already reported but never fixed:
    https://wordpress.org/support/topic/character-converted-to-a-m-p/

    Actually nobody ever replied to the bug report.

    This is a PHP code snippet generated by Ad Inserter to be processed by W3TC:
    if ($ai_amp_page && !$ai_amp_enabled)

    This is what AMP plugin generates on AMP page:
    if ($ai_amp_page & amp;amp;& amp;amp; !$ai_amp_enabled)

    There are no spaces between & and amp – I put them to preserve the code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Issue with AMP’ is closed to new replies.