* AMP infinite scroll separator.
* @module infinite-scroll
* @param string '' The markup for the next page separator.
apply_filters( 'jetpack_amp_infinite_separator', '' )
<div recommendation-box class="recommendation-box">
<template type="amp-mustache">
* AMP infinite scroll older posts markup.
* @module infinite-scroll
* @param string '' The markup for the older posts/next page.
apply_filters( 'jetpack_amp_infinite_older_posts', '' )
* Get the AMP next page information.
protected function amp_next_page() {
if ( ! static::amp_is_last_page() ) {
max( get_query_var( 'paged', 1 ), 1 ) + 1,
$url = get_next_posts_page_link();
* The next page settings.
* - title => The title to be featured on the browser tab.
* - url => The URL of next page.
* - image => The image URL. A required AMP setting, not in use currently. Themes are welcome to leverage.
* @module infinite-scroll
* @param array $next_page The contents of the output buffer.
return apply_filters( 'jetpack_amp_infinite_next_page_data', $next_page );
* Get the number of pages left.
protected static function amp_get_max_pages() {
return (int) $wp_query->max_num_pages - (int) $wp_query->query_vars['paged'];
protected static function amp_is_last_page() {
return 0 === static::amp_get_max_pages();
* Initialize The_Neverending_Home_Page
function the_neverending_home_page_init() {
if ( ! current_theme_supports( 'infinite-scroll' ) ) {
new The_Neverending_Home_Page();
add_action( 'init', 'the_neverending_home_page_init', 20 );
* Check whether the current theme is infinite-scroll aware.
* If so, include the files which add theme support.
function the_neverending_home_page_theme_support() {
defined( 'IS_WPCOM' ) && IS_WPCOM &&
defined( 'REST_API_REQUEST' ) && REST_API_REQUEST &&
! doing_action( 'restapi_theme_after_setup_theme' )
// Don't source theme compat files until we're in the site's context
$theme_name = get_stylesheet();
* Filter the path to the Infinite Scroll compatibility file.
* @module infinite-scroll
* @param string $str IS compatibility file path.
* @param string $theme_name Theme name.
$customization_file = apply_filters( 'infinite_scroll_customization_file', __DIR__ . "/themes/{$theme_name}.php", $theme_name );
if ( is_readable( $customization_file ) ) {
require_once $customization_file;
add_action( 'after_setup_theme', 'the_neverending_home_page_theme_support', 5 );
* Early accommodation of the Infinite Scroll AJAX request
if ( The_Neverending_Home_Page::got_infinity() ) {
* If we're sure this is an AJAX request (i.e. the HTTP_X_REQUESTED_WITH header says so),
* indicate it as early as possible for actions like init
if ( ! defined( 'DOING_AJAX' ) &&
isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) &&
strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) ) === 'XMLHTTPREQUEST'
define( 'DOING_AJAX', true );
// Don't load the admin bar when doing the AJAX response.