Skip to content

Instantly share code, notes, and snippets.

@remyperona
Created March 24, 2017 21:55
Show Gist options
  • Save remyperona/88c0fe71464f56f70a5aea3ce3b0e535 to your computer and use it in GitHub Desktop.
Save remyperona/88c0fe71464f56f70a5aea3ce3b0e535 to your computer and use it in GitHub Desktop.
<?php
function rocket_disable_rewrite_amp() {
if ( defined( 'AMP_QUERY_VAR' ) && function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
// this filter is documented in inc/front/protocol.php
$do_rocket_protocol_rewrite = apply_filters( 'do_rocket_protocol_rewrite', false );
if ( ( get_rocket_option( 'do_cloudflare', 0 ) && get_rocket_option( 'cloudflare_protocol_rewrite', 0 ) || $do_rocket_protocol_rewrite ) ) {
remove_filter( 'rocket_buffer', '__rocket_protocol_rewrite', PHP_INT_MAX );
remove_filter( 'wp_calculate_image_srcset', '__rocket_protocol_rewrite_srcset', PHP_INT_MAX );
}
}
}
add_action( 'wp', 'rocket_disable_rewrite_amp' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment