Created
March 21, 2016 22:25
-
-
Save larsschenk/a2052309db259219a9f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Disable NewRelic at AMP | |
* Description: Removes NewRelic script code from AMP pages | |
* Plugin URI: http://www.lars-schenk.com/ | |
* Version: 0.0.2 | |
* Author: Lars Schenk | |
* Author URI: http://www.lars-schenk.com | |
* Licence: MIT | |
* License URI: http://opensource.org/licenses/MIT | |
* | |
* Synopsis: | |
* Disable NewRelic when AMP pages are served. | |
* This works only when pages will not be served via advanced cache. | |
* When advanced cache is serving the page, no hooks will be fired and | |
* no plugins will be loaded. Not even mu-plugins. | |
* | |
* So we have to disable the extension in the advanced cache. | |
* See | |
* https://github.com/petermolnar/wp-ffpc/pull/47 | |
*/ | |
add_action('muplugins_loaded', 'disable_newrelic_at_amp'); | |
function disable_newrelic_at_amp() | |
{ | |
if (stripos($_SERVER["REQUEST_URI"], '/amp/')) { | |
if (extension_loaded('newrelic')) { | |
newrelic_disable_autorum(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment