Last active
March 5, 2019 21:15
-
-
Save glueckpress/cff7475b113b75cb2a426ead6d6190c0 to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket]Disable all WP Rocket functions on AMP pages created by the Automattic AMP plugin.
This file contains hidden or 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 | |
/** | |
* UNTESTED EXAMPLE! | |
* Please don’t use in production without having tested it before! | |
* @link http://wordpress.stackexchange.com/a/12165 | |
* @return void | |
*/ | |
function example__disable_rocket_cache_for_amp_pages() { | |
if ( ! defined( 'AMP_QUERY_VAR' ) ) | |
return; | |
if ( ! function_exists( 'is_amp_endpoint' ) ) | |
return; | |
if ( is_amp_endpoint() ) | |
deactivate_plugins( '/wp-rocket/wp-rocket.php', true ); // true => silent deactivation, no deactivation hooks called | |
} | |
add_action( 'wp', 'example__disable_rocket_cache_for_amp_pages' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need to use this. where I have to put it? in the theme functions.php or somewhere else?