Created
November 10, 2020 21:45
-
-
Save westonruter/a9ed25d4fb5a31f6c9cae2b6fa076c7a 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 | |
/** | |
* Jetpack AMP Infinite Scroll Disable plugin bootstrap. | |
* | |
* @package Google\Mini_Plugin_Template | |
* @author Weston Ruter, Google | |
* @license GPL-2.0-or-later | |
* @copyright 2020 Google Inc. | |
* | |
* @wordpress-plugin | |
* Plugin Name: Jetpack AMP Infinite Scroll Disable | |
* Plugin URI: https://gist.github.com/westonruter/a9ed25d4fb5a31f6c9cae2b6fa076c7a | |
* Description: Disable Jetpack's Infinite Scroll on AMP pages. This is a workaround for a broken AMP implementation in Jetpack. See <a href="https://github.com/Automattic/jetpack/pull/17497">jetpack#17497</a>. | |
* Version: 0.1 | |
* Author: Weston Ruter, Google | |
* Author URI: https://weston.ruter.net/ | |
* License: GNU General Public License v2 (or later) | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
* Gist Plugin URI: https://gist.github.com/westonruter/a9ed25d4fb5a31f6c9cae2b6fa076c7a | |
*/ | |
add_action( | |
'plugins_loaded', | |
function () { | |
$priority = has_action( 'init', 'the_neverending_home_page_init' ); | |
if ( false === $priority ) { | |
return; | |
} | |
remove_action( 'init', 'the_neverending_home_page_init', $priority ); | |
add_action( | |
'wp', | |
function () { | |
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { | |
return; | |
} | |
the_neverending_home_page_init(); | |
}, | |
~PHP_INT_MAX | |
); | |
}, | |
PHP_INT_MAX | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation instructions: https://gist.github.com/westonruter/6110fbc4bef0c4b8c021a112012f7e9c