• Resolved markifornia

    (@markifornia)


    Hey guys and gals,

    I tried finding a similar post regarding this topic but couldn’t so I’m posting.

    First the code:

    Features.php line 1820
    // 15. Disable New Relic’s extra script that its adds in AMP pages.
    add_action( ‘amp_post_template_data’, ‘ampforwp_disable_new_relic_scripts’ );
    if ( ! function_exists(‘ampforwp_disable_new_relic_scripts’) ) {
    function ampforwp_disable_new_relic_scripts( $data ) {
    if ( ! function_exists( ‘newrelic_disable_autorum’ ) ) {
    return $data;
    }
    if ( function_exists( ‘ampforwp_is_amp_endpoint’ ) && ampforwp_is_amp_endpoint() ) {
    newrelic_disable_autorum();
    }
    return $data;
    }
    }

    Is this code working for anyone? – this doesn’t seem to be catching New Relic code from being injected into AMP pages. Therefore we are continuously failing AMP validation tests.

    In addition to further ensuring New Relic scripts don’t get loaded into AMP pages, we’ve implemented below in our function.php file:

    //Remove new relic from amp pages
    if (function_exists(‘newrelic_disable_autorum’)) {
    add_action(‘init’, function() {
    $url = $_SERVER[‘REQUEST_URI’];
    if(strpos($url, ‘/amp/’) !== false){
    newrelic_disable_autorum();
    }
    });
    };

    I’ve scoured the interwebs and most state the same solution above – in some variation.

    AMP pages with New Relic scripts injected to it will continue to fail AMP validation tests – is anyone experiencing the same issue? Any work arounds or solutions?

    Thanks all – again and great plugin!

    -Mark

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