Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/infinite...
File: infinity.php
);
[500] Fix | Delete
[501] Fix | Delete
// Add our default styles.
[502] Fix | Delete
wp_register_style( 'the-neverending-homepage', plugins_url( 'infinity.css', __FILE__ ), array(), '20140422' );
[503] Fix | Delete
[504] Fix | Delete
// Make sure there are enough posts for IS
[505] Fix | Delete
if ( self::is_last_batch() ) {
[506] Fix | Delete
return;
[507] Fix | Delete
}
[508] Fix | Delete
[509] Fix | Delete
// Add our scripts.
[510] Fix | Delete
wp_enqueue_script( 'the-neverending-homepage' );
[511] Fix | Delete
[512] Fix | Delete
// Add our default styles.
[513] Fix | Delete
wp_enqueue_style( 'the-neverending-homepage' );
[514] Fix | Delete
[515] Fix | Delete
add_action( 'wp_footer', array( $this, 'action_wp_footer_settings' ), 2 );
[516] Fix | Delete
[517] Fix | Delete
add_action( 'wp_footer', array( $this, 'action_wp_footer' ), 21 ); // Core prints footer scripts at priority 20, so we just need to be one later than that
[518] Fix | Delete
[519] Fix | Delete
add_filter( 'infinite_scroll_results', array( $this, 'filter_infinite_scroll_results' ), 10, 3 );
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
/**
[523] Fix | Delete
* Initialize the Customizer logic separately from the main JS.
[524] Fix | Delete
*
[525] Fix | Delete
* @since 8.4.0
[526] Fix | Delete
*/
[527] Fix | Delete
public function init_customizer_assets() {
[528] Fix | Delete
// Add our scripts.
[529] Fix | Delete
wp_register_script(
[530] Fix | Delete
'the-neverending-homepage-customizer',
[531] Fix | Delete
Assets::get_file_url_for_environment(
[532] Fix | Delete
'_inc/build/infinite-scroll/infinity-customizer.min.js',
[533] Fix | Delete
'modules/infinite-scroll/infinity-customizer.js'
[534] Fix | Delete
),
[535] Fix | Delete
array( 'jquery', 'customize-base' ),
[536] Fix | Delete
JETPACK__VERSION . '-is5.0.0', // Added for ability to cachebust on WP.com.
[537] Fix | Delete
true
[538] Fix | Delete
);
[539] Fix | Delete
[540] Fix | Delete
wp_enqueue_script( 'the-neverending-homepage-customizer' );
[541] Fix | Delete
}
[542] Fix | Delete
[543] Fix | Delete
/**
[544] Fix | Delete
* Returns classes to be added to <body>. If it's enabled, 'infinite-scroll'. If set to continuous scroll, adds 'neverending' too.
[545] Fix | Delete
*
[546] Fix | Delete
* @since 4.7.0 No longer added as a 'body_class' filter but passed to JS environment and added using JS.
[547] Fix | Delete
*
[548] Fix | Delete
* @return string
[549] Fix | Delete
*/
[550] Fix | Delete
public function body_class() {
[551] Fix | Delete
$settings = self::get_settings();
[552] Fix | Delete
$classes = '';
[553] Fix | Delete
// Do not add infinity-scroll class if disabled through the Reading page
[554] Fix | Delete
$disabled = '' === get_option( self::$option_name_enabled ) ? true : false;
[555] Fix | Delete
if ( ! $disabled || 'click' === $settings->type ) {
[556] Fix | Delete
$classes = 'infinite-scroll';
[557] Fix | Delete
[558] Fix | Delete
if ( 'scroll' === $settings->type ) {
[559] Fix | Delete
$classes .= ' neverending';
[560] Fix | Delete
}
[561] Fix | Delete
}
[562] Fix | Delete
[563] Fix | Delete
return $classes;
[564] Fix | Delete
}
[565] Fix | Delete
[566] Fix | Delete
/**
[567] Fix | Delete
* In case IS is activated on search page, we have to exclude initially loaded posts which match the keyword by title, not the content as they are displayed before content-matching ones
[568] Fix | Delete
*
[569] Fix | Delete
* @uses self::wp_query
[570] Fix | Delete
* @uses self::get_last_post_date
[571] Fix | Delete
* @uses self::has_only_title_matching_posts
[572] Fix | Delete
* @return array
[573] Fix | Delete
*/
[574] Fix | Delete
public function get_excluded_posts() {
[575] Fix | Delete
[576] Fix | Delete
$excluded_posts = array();
[577] Fix | Delete
// loop through posts returned by wp_query call
[578] Fix | Delete
foreach ( self::wp_query()->get_posts() as $post ) {
[579] Fix | Delete
if ( ! $post instanceof \WP_Post ) {
[580] Fix | Delete
continue;
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
$orderby = isset( self::wp_query()->query_vars['orderby'] ) ? self::wp_query()->query_vars['orderby'] : '';
[584] Fix | Delete
$post_date = ( ! empty( $post->post_date ) ? $post->post_date : false );
[585] Fix | Delete
if ( 'modified' === $orderby || false === $post_date ) {
[586] Fix | Delete
$post_date = $post->post_modified;
[587] Fix | Delete
}
[588] Fix | Delete
[589] Fix | Delete
// in case all posts initially displayed match the keyword by title we add em all to excluded posts array
[590] Fix | Delete
// else, we add only posts which are older than last_post_date param as newer are natually excluded by last_post_date condition in the SQL query
[591] Fix | Delete
if ( self::has_only_title_matching_posts() || $post_date <= self::get_last_post_date() ) {
[592] Fix | Delete
array_push( $excluded_posts, $post->ID );
[593] Fix | Delete
}
[594] Fix | Delete
}
[595] Fix | Delete
return $excluded_posts;
[596] Fix | Delete
}
[597] Fix | Delete
[598] Fix | Delete
/**
[599] Fix | Delete
* In case IS is active on search, we have to exclude posts matched by title rather than by post_content in order to prevent dupes on next pages
[600] Fix | Delete
*
[601] Fix | Delete
* @uses self::wp_query
[602] Fix | Delete
* @uses self::get_excluded_posts
[603] Fix | Delete
* @return array
[604] Fix | Delete
*/
[605] Fix | Delete
public function get_query_vars() {
[606] Fix | Delete
[607] Fix | Delete
$query_vars = self::wp_query()->query_vars;
[608] Fix | Delete
// applies to search page only
[609] Fix | Delete
if ( true === self::wp_query()->is_search() ) {
[610] Fix | Delete
// set post__not_in array in query_vars in case it does not exists
[611] Fix | Delete
if ( false === isset( $query_vars['post__not_in'] ) ) {
[612] Fix | Delete
$query_vars['post__not_in'] = array();
[613] Fix | Delete
}
[614] Fix | Delete
// get excluded posts
[615] Fix | Delete
$excluded = self::get_excluded_posts();
[616] Fix | Delete
// merge them with other post__not_in posts (eg.: sticky posts)
[617] Fix | Delete
$query_vars['post__not_in'] = array_merge( $query_vars['post__not_in'], $excluded );
[618] Fix | Delete
}
[619] Fix | Delete
return $query_vars;
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
/**
[623] Fix | Delete
* This function checks whether all posts returned by initial wp_query match the keyword by title
[624] Fix | Delete
* The code used in this function is borrowed from WP_Query class where it is used to construct like conditions for keywords
[625] Fix | Delete
*
[626] Fix | Delete
* @uses self::wp_query
[627] Fix | Delete
* @return bool
[628] Fix | Delete
*/
[629] Fix | Delete
public function has_only_title_matching_posts() {
[630] Fix | Delete
[631] Fix | Delete
// apply following logic for search page results only
[632] Fix | Delete
if ( false === self::wp_query()->is_search() ) {
[633] Fix | Delete
return false;
[634] Fix | Delete
}
[635] Fix | Delete
[636] Fix | Delete
// grab the last posts in the stack as if the last one is title-matching the rest is title-matching as well
[637] Fix | Delete
$post = end( self::wp_query()->posts );
[638] Fix | Delete
[639] Fix | Delete
// code inspired by WP_Query class
[640] Fix | Delete
if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', self::wp_query()->get( 's' ), $matches ) ) {
[641] Fix | Delete
$search_terms = self::wp_query()->query_vars['search_terms'] ?? null;
[642] Fix | Delete
// if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence
[643] Fix | Delete
if ( empty( $search_terms ) || ! is_countable( $search_terms ) || count( $search_terms ) > 9 ) {
[644] Fix | Delete
$search_terms = array( self::wp_query()->get( 's' ) );
[645] Fix | Delete
}
[646] Fix | Delete
} else {
[647] Fix | Delete
$search_terms = array( self::wp_query()->get( 's' ) );
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
// actual testing. As search query combines multiple keywords with AND, it's enough to check if any of the keywords is present in the title
[651] Fix | Delete
$term = current( $search_terms );
[652] Fix | Delete
if ( ! empty( $term ) && str_contains( $post->post_title, $term ) ) {
[653] Fix | Delete
return true;
[654] Fix | Delete
}
[655] Fix | Delete
[656] Fix | Delete
return false;
[657] Fix | Delete
}
[658] Fix | Delete
[659] Fix | Delete
/**
[660] Fix | Delete
* Grab the timestamp for the initial query's last post.
[661] Fix | Delete
*
[662] Fix | Delete
* This takes into account the query's 'orderby' parameter and returns
[663] Fix | Delete
* false if the posts are not ordered by date.
[664] Fix | Delete
*
[665] Fix | Delete
* @uses self::got_infinity
[666] Fix | Delete
* @uses self::has_only_title_matching_posts
[667] Fix | Delete
* @uses self::wp_query
[668] Fix | Delete
* @return string 'Y-m-d H:i:s' or false
[669] Fix | Delete
*/
[670] Fix | Delete
public function get_last_post_date() {
[671] Fix | Delete
if ( self::got_infinity() ) {
[672] Fix | Delete
return;
[673] Fix | Delete
}
[674] Fix | Delete
[675] Fix | Delete
if ( ! self::wp_query()->have_posts() ) {
[676] Fix | Delete
return null;
[677] Fix | Delete
}
[678] Fix | Delete
[679] Fix | Delete
// In case there are only title-matching posts in the initial WP_Query result, we don't want to use the last_post_date param yet
[680] Fix | Delete
if ( true === self::has_only_title_matching_posts() ) {
[681] Fix | Delete
return false;
[682] Fix | Delete
}
[683] Fix | Delete
[684] Fix | Delete
$post = end( self::wp_query()->posts );
[685] Fix | Delete
$orderby = isset( self::wp_query()->query_vars['orderby'] ) ?
[686] Fix | Delete
self::wp_query()->query_vars['orderby'] : '';
[687] Fix | Delete
$post_date = ( ! empty( $post->post_date ) ? $post->post_date : false );
[688] Fix | Delete
switch ( $orderby ) {
[689] Fix | Delete
case 'modified':
[690] Fix | Delete
return $post->post_modified;
[691] Fix | Delete
case 'date':
[692] Fix | Delete
case '':
[693] Fix | Delete
return $post_date;
[694] Fix | Delete
default:
[695] Fix | Delete
return false;
[696] Fix | Delete
}
[697] Fix | Delete
}
[698] Fix | Delete
[699] Fix | Delete
/**
[700] Fix | Delete
* Returns the appropriate `wp_posts` table field for a given query's
[701] Fix | Delete
* 'orderby' parameter, if applicable.
[702] Fix | Delete
*
[703] Fix | Delete
* @param object $query - an optional query object.
[704] Fix | Delete
* @uses self::wp_query
[705] Fix | Delete
* @return string or false
[706] Fix | Delete
*/
[707] Fix | Delete
public function get_query_sort_field( $query = null ) {
[708] Fix | Delete
if ( empty( $query ) ) {
[709] Fix | Delete
$query = self::wp_query();
[710] Fix | Delete
}
[711] Fix | Delete
[712] Fix | Delete
$orderby = isset( $query->query_vars['orderby'] ) ? $query->query_vars['orderby'] : '';
[713] Fix | Delete
[714] Fix | Delete
switch ( $orderby ) {
[715] Fix | Delete
case 'modified':
[716] Fix | Delete
return 'post_modified';
[717] Fix | Delete
case 'date':
[718] Fix | Delete
case '':
[719] Fix | Delete
return 'post_date';
[720] Fix | Delete
default:
[721] Fix | Delete
return false;
[722] Fix | Delete
}
[723] Fix | Delete
}
[724] Fix | Delete
[725] Fix | Delete
/**
[726] Fix | Delete
* Create a where clause that will make sure post queries return posts
[727] Fix | Delete
* in the correct order, without duplicates, if a new post is added
[728] Fix | Delete
* and we're sorting by post date.
[729] Fix | Delete
*
[730] Fix | Delete
* @global $wpdb
[731] Fix | Delete
* @param string $where - the where clause.
[732] Fix | Delete
* @param object $query - the query.
[733] Fix | Delete
* @uses apply_filters
[734] Fix | Delete
* @filter posts_where
[735] Fix | Delete
* @return string
[736] Fix | Delete
*/
[737] Fix | Delete
public function query_time_filter( $where, $query ) {
[738] Fix | Delete
if ( self::got_infinity() ) {
[739] Fix | Delete
global $wpdb;
[740] Fix | Delete
[741] Fix | Delete
$sort_field = self::get_query_sort_field( $query );
[742] Fix | Delete
[743] Fix | Delete
if ( 'post_date' !== $sort_field ||
[744] Fix | Delete
! isset( $_REQUEST['query_args']['order'] ) || 'DESC' !== $_REQUEST['query_args']['order'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
[745] Fix | Delete
return $where;
[746] Fix | Delete
}
[747] Fix | Delete
[748] Fix | Delete
$query_before = isset( $_REQUEST['query_before'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['query_before'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
[749] Fix | Delete
[750] Fix | Delete
if ( empty( $query_before ) ) {
[751] Fix | Delete
return $where;
[752] Fix | Delete
}
[753] Fix | Delete
[754] Fix | Delete
// Construct the date query using our timestamp
[755] Fix | Delete
$clause = $wpdb->prepare( " AND {$wpdb->posts}.post_date <= %s", $query_before );
[756] Fix | Delete
[757] Fix | Delete
/**
[758] Fix | Delete
* Filter Infinite Scroll's SQL date query making sure post queries
[759] Fix | Delete
* will always return results prior to (descending sort)
[760] Fix | Delete
* or before (ascending sort) the last post date.
[761] Fix | Delete
*
[762] Fix | Delete
* @deprecated 14.0
[763] Fix | Delete
*
[764] Fix | Delete
* @module infinite-scroll
[765] Fix | Delete
*
[766] Fix | Delete
* @param string $clause SQL Date query.
[767] Fix | Delete
* @param object $query Query.
[768] Fix | Delete
* @param string $operator @deprecated Query operator.
[769] Fix | Delete
* @param string $last_post_date @deprecated Last Post Date timestamp.
[770] Fix | Delete
*/
[771] Fix | Delete
$operator = '<';
[772] Fix | Delete
$last_post_date = isset( $_REQUEST['last_post_date'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['last_post_date'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes to the site
[773] Fix | Delete
$where .= apply_filters_deprecated( 'infinite_scroll_posts_where', array( $clause, $query, $operator, $last_post_date ), '14.0', '' );
[774] Fix | Delete
}
[775] Fix | Delete
[776] Fix | Delete
return $where;
[777] Fix | Delete
}
[778] Fix | Delete
[779] Fix | Delete
/**
[780] Fix | Delete
* Let's overwrite the default post_per_page setting to always display a fixed amount.
[781] Fix | Delete
*
[782] Fix | Delete
* @param object $query - the query.
[783] Fix | Delete
* @uses is_admin, self::archive_supports_infinity, self::get_settings
[784] Fix | Delete
*/
[785] Fix | Delete
public function posts_per_page_query( $query ) {
[786] Fix | Delete
if ( ! is_admin() && self::archive_supports_infinity() && $query->is_main_query() ) {
[787] Fix | Delete
$query->set( 'posts_per_page', self::posts_per_page() );
[788] Fix | Delete
}
[789] Fix | Delete
}
[790] Fix | Delete
[791] Fix | Delete
/**
[792] Fix | Delete
* Check if the IS output should be wrapped in a div.
[793] Fix | Delete
* Setting value can be a boolean or a string specifying the class applied to the div.
[794] Fix | Delete
*
[795] Fix | Delete
* @uses self::get_settings
[796] Fix | Delete
* @return bool
[797] Fix | Delete
*/
[798] Fix | Delete
public function has_wrapper() {
[799] Fix | Delete
return (bool) self::get_settings()->wrapper;
[800] Fix | Delete
}
[801] Fix | Delete
[802] Fix | Delete
/**
[803] Fix | Delete
* Returns the Ajax url
[804] Fix | Delete
*
[805] Fix | Delete
* @global $wp
[806] Fix | Delete
* @uses home_url, add_query_arg, apply_filters
[807] Fix | Delete
* @return string
[808] Fix | Delete
*/
[809] Fix | Delete
public function ajax_url() {
[810] Fix | Delete
$base_url = set_url_scheme( home_url( '/' ) );
[811] Fix | Delete
[812] Fix | Delete
$ajaxurl = add_query_arg( array( 'infinity' => 'scrolling' ), $base_url );
[813] Fix | Delete
[814] Fix | Delete
/**
[815] Fix | Delete
* Filter the Infinite Scroll Ajax URL.
[816] Fix | Delete
*
[817] Fix | Delete
* @module infinite-scroll
[818] Fix | Delete
*
[819] Fix | Delete
* @since 2.0.0
[820] Fix | Delete
*
[821] Fix | Delete
* @param string $ajaxurl Infinite Scroll Ajax URL.
[822] Fix | Delete
*/
[823] Fix | Delete
return apply_filters( 'infinite_scroll_ajax_url', $ajaxurl );
[824] Fix | Delete
}
[825] Fix | Delete
[826] Fix | Delete
/**
[827] Fix | Delete
* Our own Ajax response, avoiding calling admin-ajax
[828] Fix | Delete
*/
[829] Fix | Delete
public function ajax_response() {
[830] Fix | Delete
// Only proceed if the url query has a key of "Infinity"
[831] Fix | Delete
if ( ! self::got_infinity() ) {
[832] Fix | Delete
return false;
[833] Fix | Delete
}
[834] Fix | Delete
[835] Fix | Delete
// This should already be defined below, but make sure.
[836] Fix | Delete
if ( ! defined( 'DOING_AJAX' ) ) {
[837] Fix | Delete
define( 'DOING_AJAX', true );
[838] Fix | Delete
}
[839] Fix | Delete
[840] Fix | Delete
@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[841] Fix | Delete
send_nosniff_header();
[842] Fix | Delete
[843] Fix | Delete
/**
[844] Fix | Delete
* Fires at the end of the Infinite Scroll Ajax response.
[845] Fix | Delete
*
[846] Fix | Delete
* @module infinite-scroll
[847] Fix | Delete
*
[848] Fix | Delete
* @since 2.0.0
[849] Fix | Delete
*/
[850] Fix | Delete
do_action( 'custom_ajax_infinite_scroll' );
[851] Fix | Delete
die( '0' );
[852] Fix | Delete
}
[853] Fix | Delete
[854] Fix | Delete
/**
[855] Fix | Delete
* Alias for renamed class method.
[856] Fix | Delete
*
[857] Fix | Delete
* Previously, JS settings object was unnecessarily output in the document head.
[858] Fix | Delete
* When the hook was changed, the method name no longer made sense.
[859] Fix | Delete
*/
[860] Fix | Delete
public function action_wp_head() {
[861] Fix | Delete
$this->action_wp_footer_settings();
[862] Fix | Delete
}
[863] Fix | Delete
[864] Fix | Delete
/**
[865] Fix | Delete
* Prints the relevant infinite scroll settings in JS.
[866] Fix | Delete
*
[867] Fix | Delete
* @global $wp_rewrite
[868] Fix | Delete
* @uses self::get_settings, esc_js, esc_url_raw, self::has_wrapper, __, apply_filters, do_action, self::get_query_vars
[869] Fix | Delete
* @action wp_footer
[870] Fix | Delete
*/
[871] Fix | Delete
public function action_wp_footer_settings() {
[872] Fix | Delete
global $wp_rewrite;
[873] Fix | Delete
global $currentday;
[874] Fix | Delete
[875] Fix | Delete
$settings = self::get_settings();
[876] Fix | Delete
[877] Fix | Delete
// Default click handle text
[878] Fix | Delete
$click_handle_text = __( 'Older posts', 'jetpack' );
[879] Fix | Delete
[880] Fix | Delete
// If a single CPT is displayed, use its plural name instead of "posts"
[881] Fix | Delete
// Could be empty (posts) or an array of multiple post types.
[882] Fix | Delete
// In the latter two cases cases, the default text is used, leaving the `infinite_scroll_js_settings` filter for further customization.
[883] Fix | Delete
$post_type = self::wp_query()->get( 'post_type' );
[884] Fix | Delete
[885] Fix | Delete
// If it's a taxonomy, try to change the button text.
[886] Fix | Delete
if ( is_tax() ) {
[887] Fix | Delete
// Get current taxonomy slug.
[888] Fix | Delete
$taxonomy_slug = self::wp_query()->get( 'taxonomy' );
[889] Fix | Delete
[890] Fix | Delete
// Get taxonomy settings.
[891] Fix | Delete
$taxonomy = get_taxonomy( $taxonomy_slug );
[892] Fix | Delete
[893] Fix | Delete
// Check if the taxonomy is attached to one post type only and use its plural name.
[894] Fix | Delete
// If not, use "Posts" without confusing the users.
[895] Fix | Delete
if (
[896] Fix | Delete
is_a( $taxonomy, 'WP_Taxonomy' )
[897] Fix | Delete
&& is_countable( $taxonomy->object_type )
[898] Fix | Delete
&& ! empty( $taxonomy->object_type )
[899] Fix | Delete
&& count( $taxonomy->object_type ) < 2
[900] Fix | Delete
) {
[901] Fix | Delete
$post_type = $taxonomy->object_type[0];
[902] Fix | Delete
}
[903] Fix | Delete
}
[904] Fix | Delete
[905] Fix | Delete
if ( is_string( $post_type ) && ! empty( $post_type ) ) {
[906] Fix | Delete
$post_type = get_post_type_object( $post_type );
[907] Fix | Delete
[908] Fix | Delete
if ( is_object( $post_type ) && ! is_wp_error( $post_type ) ) {
[909] Fix | Delete
if ( isset( $post_type->labels->name ) ) {
[910] Fix | Delete
$cpt_text = $post_type->labels->name;
[911] Fix | Delete
} elseif ( isset( $post_type->label ) ) {
[912] Fix | Delete
$cpt_text = $post_type->label;
[913] Fix | Delete
}
[914] Fix | Delete
[915] Fix | Delete
if ( isset( $cpt_text ) ) {
[916] Fix | Delete
/* translators: %s is the name of a custom post type */
[917] Fix | Delete
$click_handle_text = sprintf( __( 'More %s', 'jetpack' ), $cpt_text );
[918] Fix | Delete
unset( $cpt_text );
[919] Fix | Delete
}
[920] Fix | Delete
}
[921] Fix | Delete
}
[922] Fix | Delete
[923] Fix | Delete
unset( $post_type );
[924] Fix | Delete
[925] Fix | Delete
// Base JS settings
[926] Fix | Delete
$js_settings = array(
[927] Fix | Delete
'id' => $settings->container,
[928] Fix | Delete
'ajaxurl' => esc_url_raw( self::ajax_url() ),
[929] Fix | Delete
'type' => esc_js( $settings->type ),
[930] Fix | Delete
'wrapper' => self::has_wrapper(),
[931] Fix | Delete
'wrapper_class' => is_string( $settings->wrapper ) ? esc_js( $settings->wrapper ) : 'infinite-wrap',
[932] Fix | Delete
'footer' => is_string( $settings->footer ) ? esc_js( $settings->footer ) : $settings->footer,
[933] Fix | Delete
'click_handle' => esc_js( $settings->click_handle ),
[934] Fix | Delete
'text' => esc_js( $click_handle_text ),
[935] Fix | Delete
'totop' => __( 'Scroll back to top', 'jetpack' ),
[936] Fix | Delete
'currentday' => $currentday,
[937] Fix | Delete
'order' => 'DESC',
[938] Fix | Delete
'scripts' => array(),
[939] Fix | Delete
'styles' => array(),
[940] Fix | Delete
'google_analytics' => false,
[941] Fix | Delete
'offset' => max( 1, self::wp_query()->get( 'paged' ) ), // Pass through the current page so we can use that to offset the first load.
[942] Fix | Delete
'history' => array(
[943] Fix | Delete
'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( esc_url( get_home_url() ) ) ),
[944] Fix | Delete
'path' => self::get_request_path(),
[945] Fix | Delete
'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
[946] Fix | Delete
'parameters' => self::get_request_parameters(),
[947] Fix | Delete
),
[948] Fix | Delete
'query_args' => self::get_query_vars(),
[949] Fix | Delete
'query_before' => current_time( 'mysql' ),
[950] Fix | Delete
'last_post_date' => self::get_last_post_date(),
[951] Fix | Delete
'body_class' => self::body_class(),
[952] Fix | Delete
'loading_text' => __( 'Loading new page', 'jetpack' ),
[953] Fix | Delete
);
[954] Fix | Delete
[955] Fix | Delete
// Optional order param
[956] Fix | Delete
if ( isset( $_REQUEST['order'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
[957] Fix | Delete
$order = strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
[958] Fix | Delete
[959] Fix | Delete
if ( in_array( $order, array( 'ASC', 'DESC' ), true ) ) {
[960] Fix | Delete
$js_settings['order'] = $order;
[961] Fix | Delete
}
[962] Fix | Delete
}
[963] Fix | Delete
[964] Fix | Delete
/**
[965] Fix | Delete
* Filter the Infinite Scroll JS settings outputted in the head.
[966] Fix | Delete
*
[967] Fix | Delete
* @module infinite-scroll
[968] Fix | Delete
*
[969] Fix | Delete
* @since 2.0.0
[970] Fix | Delete
*
[971] Fix | Delete
* @param array $js_settings Infinite Scroll JS settings.
[972] Fix | Delete
*/
[973] Fix | Delete
$js_settings = apply_filters( 'infinite_scroll_js_settings', $js_settings );
[974] Fix | Delete
[975] Fix | Delete
/**
[976] Fix | Delete
* Fires before Infinite Scroll outputs inline JavaScript in the head.
[977] Fix | Delete
*
[978] Fix | Delete
* @module infinite-scroll
[979] Fix | Delete
*
[980] Fix | Delete
* @since 2.0.0
[981] Fix | Delete
*/
[982] Fix | Delete
do_action( 'infinite_scroll_wp_head' );
[983] Fix | Delete
[984] Fix | Delete
?>
[985] Fix | Delete
<script type="text/javascript">
[986] Fix | Delete
var infiniteScroll = <?php echo wp_json_encode( array( 'settings' => $js_settings ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>;
[987] Fix | Delete
</script>
[988] Fix | Delete
<?php
[989] Fix | Delete
}
[990] Fix | Delete
[991] Fix | Delete
// phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
[992] Fix | Delete
[993] Fix | Delete
/**
[994] Fix | Delete
* Build path data for current request.
[995] Fix | Delete
* Used for Google Analytics and pushState history tracking.
[996] Fix | Delete
*
[997] Fix | Delete
* @global $wp_rewrite
[998] Fix | Delete
* @global $wp
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function