Skip to content

Instantly share code, notes, and snippets.

@schlessera
Last active March 29, 2021 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schlessera/3c279bac46b3437966e5812901e5f923 to your computer and use it in GitHub Desktop.
Save schlessera/3c279bac46b3437966e5812901e5f923 to your computer and use it in GitHub Desktop.
AMP Disable Optimizer
<?php
/**
* AMP Disable Optimizer
*
* @package AMP_Disable_Optimizer
* @author Alain Schlesser <alain.schlesser@gmail.com>
* @link https://gist.github.com/schlessera/3c279bac46b3437966e5812901e5f923
* @license MIT
*
* @wordpress-plugin
* Plugin Name: AMP Disable Optimizer
* Plugin URI: https://gist.github.com/schlessera/3c279bac46b3437966e5812901e5f923
* Description: Disable the AMP Optimizer via the query arg <code>amp_optimizer=0</code>.
* Version: 0.1
* Author: Alain Schlesser <alain.schlesser@gmail.com>
* Author URI: https://alainschlesser.com/
* License: MIT
* Gist Plugin URI: https://gist.github.com/schlessera/3c279bac46b3437966e5812901e5f923
*/
if ( isset( $_GET['amp_optimizer'] ) && false === rest_sanitize_boolean( $_GET['amp_optimizer'] ) ) {
add_filter( 'amp_enable_optimizer', '__return_false', 100 );
} else {
add_filter( 'amp_enable_optimizer', '__return_true', 100 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment