Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created November 10, 2020 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/a9ed25d4fb5a31f6c9cae2b6fa076c7a to your computer and use it in GitHub Desktop.
Save westonruter/a9ed25d4fb5a31f6c9cae2b6fa076c7a to your computer and use it in GitHub Desktop.
<?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
);
@westonruter
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment