Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created May 17, 2019 20:22
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 westonruter/bf848ed3c8c922f192b6e2e39598e86c to your computer and use it in GitHub Desktop.
Save westonruter/bf848ed3c8c922f192b6e2e39598e86c to your computer and use it in GitHub Desktop.
The AMP plugin will eventually allow you to switch a theme that declares itself as Transitional (paired=true) to also switch to Native. In the mean time, this plugin can achieve the same effect. For more, see https://github.com/ampproject/amp-wp/issues/2312
<?php
/**
* AMP Force Native Mode
*
* @package AMP
* @license GPL-2.0+
* @copyright 2019 Google LLC
*
* @wordpress-plugin
* Plugin Name: AMP Force Native Mode
* Description: The AMP plugin will eventually <a href="https://github.com/ampproject/amp-wp/issues/2312">allow</a> you to switch a theme that declares itself as Transitional (paired=true) to also switch to Native. In the mean time, this plugin can achieve the same effect.
* Plugin URI: https://github.com/ampproject/amp-wp/issues/2312
* Author: Weston Ruter, Google
* Author URI: https://weston.ruter.net/
* Version: 1.0
* License: GPLv2 or later
*/
add_action(
'after_setup_theme',
function() {
$support = get_theme_support( 'amp' );
if ( isset( $support[0] ) && is_array( $support[0] ) ) {
$support = $support[0];
} else {
$support = array();
}
unset( $support['paired'] );
add_theme_support( 'amp', $support );
},
PHP_INT_MAX
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment