Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/infinite...
File: infinity.php
* @uses user_trailingslashit, sanitize_text_field, add_query_arg
[1000] Fix | Delete
* @return string|bool
[1001] Fix | Delete
*/
[1002] Fix | Delete
private function get_request_path() {
[1003] Fix | Delete
global $wp_rewrite;
[1004] Fix | Delete
[1005] Fix | Delete
if ( $wp_rewrite->using_permalinks() ) {
[1006] Fix | Delete
global $wp;
[1007] Fix | Delete
[1008] Fix | Delete
// If called too early, bail
[1009] Fix | Delete
if ( ! isset( $wp->request ) ) {
[1010] Fix | Delete
return false;
[1011] Fix | Delete
}
[1012] Fix | Delete
[1013] Fix | Delete
// Determine path for paginated version of current request
[1014] Fix | Delete
if ( preg_match( '#' . preg_quote( $wp_rewrite->pagination_base, '#' ) . '/\d+/?$#i', $wp->request ) ) {
[1015] Fix | Delete
$path = preg_replace( '#' . preg_quote( $wp_rewrite->pagination_base, '#' ) . '/\d+$#i', $wp_rewrite->pagination_base . '/%d', $wp->request );
[1016] Fix | Delete
} else {
[1017] Fix | Delete
$path = $wp->request . '/' . $wp_rewrite->pagination_base . '/%d';
[1018] Fix | Delete
}
[1019] Fix | Delete
[1020] Fix | Delete
// Slashes everywhere we need them
[1021] Fix | Delete
if ( ! str_starts_with( $path, '/' ) ) {
[1022] Fix | Delete
$path = '/' . $path;
[1023] Fix | Delete
}
[1024] Fix | Delete
[1025] Fix | Delete
$path = user_trailingslashit( $path );
[1026] Fix | Delete
} else {
[1027] Fix | Delete
// Clean up raw $_REQUEST input
[1028] Fix | Delete
$path = array_map( 'sanitize_text_field', wp_unslash( $_REQUEST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- seems this is used for Google Analytics and browser history tracking.
[1029] Fix | Delete
$path = array_filter( $path );
[1030] Fix | Delete
[1031] Fix | Delete
$path['paged'] = '%d';
[1032] Fix | Delete
[1033] Fix | Delete
$path = add_query_arg( $path, '/' );
[1034] Fix | Delete
}
[1035] Fix | Delete
[1036] Fix | Delete
return empty( $path ) ? false : $path;
[1037] Fix | Delete
}
[1038] Fix | Delete
[1039] Fix | Delete
/**
[1040] Fix | Delete
* Return query string for current request, prefixed with '?'.
[1041] Fix | Delete
*
[1042] Fix | Delete
* @return string
[1043] Fix | Delete
*/
[1044] Fix | Delete
private function get_request_parameters() {
[1045] Fix | Delete
$uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
[1046] Fix | Delete
$uri = preg_replace( '/^[^?]*(\?.*$)/', '$1', $uri, 1, $count );
[1047] Fix | Delete
if ( $count !== 1 ) {
[1048] Fix | Delete
return '';
[1049] Fix | Delete
}
[1050] Fix | Delete
return $uri;
[1051] Fix | Delete
}
[1052] Fix | Delete
[1053] Fix | Delete
/**
[1054] Fix | Delete
* Provide IS with a list of the scripts and stylesheets already present on the page.
[1055] Fix | Delete
* Since posts may contain require additional assets that haven't been loaded, this data will be used to track the additional assets.
[1056] Fix | Delete
*
[1057] Fix | Delete
* @global $wp_scripts, $wp_styles
[1058] Fix | Delete
* @action wp_footer
[1059] Fix | Delete
*/
[1060] Fix | Delete
public function action_wp_footer() {
[1061] Fix | Delete
global $wp_scripts, $wp_styles;
[1062] Fix | Delete
[1063] Fix | Delete
$scripts = is_a( $wp_scripts, 'WP_Scripts' ) ? $wp_scripts->done : array();
[1064] Fix | Delete
/**
[1065] Fix | Delete
* Filter the list of scripts already present on the page.
[1066] Fix | Delete
*
[1067] Fix | Delete
* @module infinite-scroll
[1068] Fix | Delete
*
[1069] Fix | Delete
* @since 2.1.2
[1070] Fix | Delete
*
[1071] Fix | Delete
* @param array $scripts Array of scripts present on the page.
[1072] Fix | Delete
*/
[1073] Fix | Delete
$scripts = apply_filters( 'infinite_scroll_existing_scripts', $scripts );
[1074] Fix | Delete
[1075] Fix | Delete
$styles = is_a( $wp_styles, 'WP_Styles' ) ? $wp_styles->done : array();
[1076] Fix | Delete
/**
[1077] Fix | Delete
* Filter the list of styles already present on the page.
[1078] Fix | Delete
*
[1079] Fix | Delete
* @module infinite-scroll
[1080] Fix | Delete
*
[1081] Fix | Delete
* @since 2.1.2
[1082] Fix | Delete
*
[1083] Fix | Delete
* @param array $styles Array of styles present on the page.
[1084] Fix | Delete
*/
[1085] Fix | Delete
$styles = apply_filters( 'infinite_scroll_existing_stylesheets', $styles );
[1086] Fix | Delete
[1087] Fix | Delete
?>
[1088] Fix | Delete
<script type="text/javascript">
[1089] Fix | Delete
(function() {
[1090] Fix | Delete
var extend = function(out) {
[1091] Fix | Delete
out = out || {};
[1092] Fix | Delete
[1093] Fix | Delete
for (var i = 1; i < arguments.length; i++) {
[1094] Fix | Delete
if (!arguments[i])
[1095] Fix | Delete
continue;
[1096] Fix | Delete
[1097] Fix | Delete
for (var key in arguments[i]) {
[1098] Fix | Delete
if (arguments[i].hasOwnProperty(key))
[1099] Fix | Delete
out[key] = arguments[i][key];
[1100] Fix | Delete
}
[1101] Fix | Delete
}
[1102] Fix | Delete
[1103] Fix | Delete
return out;
[1104] Fix | Delete
};
[1105] Fix | Delete
extend( window.infiniteScroll.settings.scripts, <?php echo wp_json_encode( $scripts, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?> );
[1106] Fix | Delete
extend( window.infiniteScroll.settings.styles, <?php echo wp_json_encode( $styles, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?> );
[1107] Fix | Delete
})();
[1108] Fix | Delete
</script>
[1109] Fix | Delete
<?php
[1110] Fix | Delete
$aria_live = 'assertive';
[1111] Fix | Delete
if ( 'scroll' === self::get_settings()->type ) {
[1112] Fix | Delete
$aria_live = 'polite';
[1113] Fix | Delete
}
[1114] Fix | Delete
?>
[1115] Fix | Delete
<span id="infinite-aria" aria-live="<?php echo esc_attr( $aria_live ); ?>"></span>
[1116] Fix | Delete
<?php
[1117] Fix | Delete
}
[1118] Fix | Delete
[1119] Fix | Delete
/**
[1120] Fix | Delete
* Identify additional scripts required by the latest set of IS posts and provide the necessary data to the IS response handler.
[1121] Fix | Delete
*
[1122] Fix | Delete
* @param array $results - the results.
[1123] Fix | Delete
* @param array $query_args - Array of Query arguments.
[1124] Fix | Delete
* @param array $wp_query - the WP query.
[1125] Fix | Delete
* @global $wp_scripts
[1126] Fix | Delete
* @uses sanitize_text_field, add_query_arg
[1127] Fix | Delete
* @filter infinite_scroll_results
[1128] Fix | Delete
* @return array
[1129] Fix | Delete
*/
[1130] Fix | Delete
public function filter_infinite_scroll_results( $results, $query_args, $wp_query ) {
[1131] Fix | Delete
// Don't bother unless there are posts to display
[1132] Fix | Delete
if ( 'success' !== $results['type'] ) {
[1133] Fix | Delete
return $results;
[1134] Fix | Delete
}
[1135] Fix | Delete
[1136] Fix | Delete
// Parse and sanitize the script handles already output
[1137] Fix | Delete
$initial_scripts = isset( $_REQUEST['scripts'] ) && is_array( $_REQUEST['scripts'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['scripts'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no site changes made.
[1138] Fix | Delete
[1139] Fix | Delete
if ( is_array( $initial_scripts ) ) {
[1140] Fix | Delete
global $wp_scripts;
[1141] Fix | Delete
[1142] Fix | Delete
// Identify new scripts needed by the latest set of IS posts
[1143] Fix | Delete
$new_scripts = array_filter(
[1144] Fix | Delete
$wp_scripts->done,
[1145] Fix | Delete
function ( $script_name ) use ( $initial_scripts ) {
[1146] Fix | Delete
// Jetpack block scripts should always be sent, even if they've been
[1147] Fix | Delete
// sent before. These scripts only run once on when loaded, they don't
[1148] Fix | Delete
// watch for new blocks being added.
[1149] Fix | Delete
if ( str_starts_with( $script_name, 'jetpack-block-' ) ) {
[1150] Fix | Delete
return true;
[1151] Fix | Delete
}
[1152] Fix | Delete
[1153] Fix | Delete
return ! in_array( $script_name, $initial_scripts, true );
[1154] Fix | Delete
}
[1155] Fix | Delete
);
[1156] Fix | Delete
[1157] Fix | Delete
// If new scripts are needed, extract relevant data from $wp_scripts
[1158] Fix | Delete
if ( ! empty( $new_scripts ) ) {
[1159] Fix | Delete
$results['scripts'] = array();
[1160] Fix | Delete
[1161] Fix | Delete
foreach ( $new_scripts as $handle ) {
[1162] Fix | Delete
// Abort if somehow the handle doesn't correspond to a registered script
[1163] Fix | Delete
// or if the script doesn't have `src` set.
[1164] Fix | Delete
$script_not_registered = ! isset( $wp_scripts->registered[ $handle ] );
[1165] Fix | Delete
$empty_src = empty( $wp_scripts->registered[ $handle ]->src );
[1166] Fix | Delete
if ( $script_not_registered || $empty_src ) {
[1167] Fix | Delete
continue;
[1168] Fix | Delete
}
[1169] Fix | Delete
[1170] Fix | Delete
$before_handle = $wp_scripts->get_inline_script_data( $handle, 'before' );
[1171] Fix | Delete
$after_handle = $wp_scripts->get_inline_script_data( $handle, 'after' );
[1172] Fix | Delete
[1173] Fix | Delete
// Provide basic script data
[1174] Fix | Delete
$script_data = array(
[1175] Fix | Delete
'handle' => $handle,
[1176] Fix | Delete
'footer' => ( is_array( $wp_scripts->in_footer ) && in_array( $handle, $wp_scripts->in_footer, true ) ),
[1177] Fix | Delete
'extra_data' => $wp_scripts->print_extra_script( $handle, false ),
[1178] Fix | Delete
'before_handle' => $before_handle,
[1179] Fix | Delete
'after_handle' => $after_handle,
[1180] Fix | Delete
);
[1181] Fix | Delete
[1182] Fix | Delete
// Base source
[1183] Fix | Delete
$src = $wp_scripts->registered[ $handle ]->src;
[1184] Fix | Delete
[1185] Fix | Delete
// Take base_url into account
[1186] Fix | Delete
if ( strpos( $src, 'http' ) !== 0 ) {
[1187] Fix | Delete
$src = $wp_scripts->base_url . $src;
[1188] Fix | Delete
}
[1189] Fix | Delete
[1190] Fix | Delete
// Version and additional arguments
[1191] Fix | Delete
if ( null === $wp_scripts->registered[ $handle ]->ver ) {
[1192] Fix | Delete
$ver = '';
[1193] Fix | Delete
} else {
[1194] Fix | Delete
$ver = $wp_scripts->registered[ $handle ]->ver ? $wp_scripts->registered[ $handle ]->ver : $wp_scripts->default_version;
[1195] Fix | Delete
}
[1196] Fix | Delete
[1197] Fix | Delete
if ( isset( $wp_scripts->args[ $handle ] ) ) {
[1198] Fix | Delete
$ver = $ver ? $ver . '&amp;' . $wp_scripts->args[ $handle ] : $wp_scripts->args[ $handle ];
[1199] Fix | Delete
}
[1200] Fix | Delete
[1201] Fix | Delete
// Full script source with version info
[1202] Fix | Delete
$script_data['src'] = add_query_arg( 'ver', $ver, $src );
[1203] Fix | Delete
[1204] Fix | Delete
// Add script to data that will be returned to IS JS
[1205] Fix | Delete
array_push( $results['scripts'], $script_data );
[1206] Fix | Delete
}
[1207] Fix | Delete
}
[1208] Fix | Delete
}
[1209] Fix | Delete
[1210] Fix | Delete
// Expose additional script data to filters, but only include in final `$results` array if needed.
[1211] Fix | Delete
if ( ! isset( $results['scripts'] ) ) {
[1212] Fix | Delete
$results['scripts'] = array();
[1213] Fix | Delete
}
[1214] Fix | Delete
[1215] Fix | Delete
/**
[1216] Fix | Delete
* Filter the additional scripts required by the latest set of IS posts.
[1217] Fix | Delete
*
[1218] Fix | Delete
* @module infinite-scroll
[1219] Fix | Delete
*
[1220] Fix | Delete
* @since 2.1.2
[1221] Fix | Delete
*
[1222] Fix | Delete
* @param array $results['scripts'] Additional scripts required by the latest set of IS posts.
[1223] Fix | Delete
* @param array|bool $initial_scripts Set of scripts loaded on each page.
[1224] Fix | Delete
* @param array $results Array of Infinite Scroll results.
[1225] Fix | Delete
* @param array $query_args Array of Query arguments.
[1226] Fix | Delete
* @param WP_Query $wp_query WP Query.
[1227] Fix | Delete
*/
[1228] Fix | Delete
$results['scripts'] = apply_filters(
[1229] Fix | Delete
'infinite_scroll_additional_scripts',
[1230] Fix | Delete
$results['scripts'],
[1231] Fix | Delete
$initial_scripts,
[1232] Fix | Delete
$results,
[1233] Fix | Delete
$query_args,
[1234] Fix | Delete
$wp_query
[1235] Fix | Delete
);
[1236] Fix | Delete
[1237] Fix | Delete
if ( empty( $results['scripts'] ) ) {
[1238] Fix | Delete
unset( $results['scripts'] );
[1239] Fix | Delete
}
[1240] Fix | Delete
[1241] Fix | Delete
// Parse and sanitize the style handles already output
[1242] Fix | Delete
$initial_styles = isset( $_REQUEST['styles'] ) && is_array( $_REQUEST['styles'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['styles'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[1243] Fix | Delete
[1244] Fix | Delete
if ( is_array( $initial_styles ) ) {
[1245] Fix | Delete
global $wp_styles;
[1246] Fix | Delete
[1247] Fix | Delete
// Identify new styles needed by the latest set of IS posts
[1248] Fix | Delete
$new_styles = array_diff( $wp_styles->done, $initial_styles );
[1249] Fix | Delete
[1250] Fix | Delete
// If new styles are needed, extract relevant data from $wp_styles
[1251] Fix | Delete
if ( ! empty( $new_styles ) ) {
[1252] Fix | Delete
$results['styles'] = array();
[1253] Fix | Delete
[1254] Fix | Delete
foreach ( $new_styles as $handle ) {
[1255] Fix | Delete
// Abort if somehow the handle doesn't correspond to a registered stylesheet
[1256] Fix | Delete
if ( ! isset( $wp_styles->registered[ $handle ] ) ) {
[1257] Fix | Delete
continue;
[1258] Fix | Delete
}
[1259] Fix | Delete
[1260] Fix | Delete
// Provide basic style data
[1261] Fix | Delete
$style_data = array(
[1262] Fix | Delete
'handle' => $handle,
[1263] Fix | Delete
'media' => 'all',
[1264] Fix | Delete
);
[1265] Fix | Delete
[1266] Fix | Delete
// Base source
[1267] Fix | Delete
$src = $wp_styles->registered[ $handle ]->src;
[1268] Fix | Delete
[1269] Fix | Delete
// Take base_url into account
[1270] Fix | Delete
if ( strpos( $src, 'http' ) !== 0 ) {
[1271] Fix | Delete
$src = $wp_styles->base_url . $src;
[1272] Fix | Delete
}
[1273] Fix | Delete
[1274] Fix | Delete
// Version and additional arguments
[1275] Fix | Delete
if ( null === $wp_styles->registered[ $handle ]->ver ) {
[1276] Fix | Delete
$ver = '';
[1277] Fix | Delete
} else {
[1278] Fix | Delete
$ver = $wp_styles->registered[ $handle ]->ver ? $wp_styles->registered[ $handle ]->ver : $wp_styles->default_version;
[1279] Fix | Delete
}
[1280] Fix | Delete
[1281] Fix | Delete
if ( isset( $wp_styles->args[ $handle ] ) ) {
[1282] Fix | Delete
$ver = $ver ? $ver . '&amp;' . $wp_styles->args[ $handle ] : $wp_styles->args[ $handle ];
[1283] Fix | Delete
}
[1284] Fix | Delete
[1285] Fix | Delete
// Full stylesheet source with version info
[1286] Fix | Delete
$style_data['src'] = add_query_arg( 'ver', $ver, $src );
[1287] Fix | Delete
[1288] Fix | Delete
// Parse stylesheet's conditional comments if present, converting to logic executable in JS
[1289] Fix | Delete
if ( isset( $wp_styles->registered[ $handle ]->extra['conditional'] ) && $wp_styles->registered[ $handle ]->extra['conditional'] ) {
[1290] Fix | Delete
// First, convert conditional comment operators to standard logical operators. %ver is replaced in JS with the IE version
[1291] Fix | Delete
$style_data['conditional'] = str_replace(
[1292] Fix | Delete
array(
[1293] Fix | Delete
'lte',
[1294] Fix | Delete
'lt',
[1295] Fix | Delete
'gte',
[1296] Fix | Delete
'gt',
[1297] Fix | Delete
),
[1298] Fix | Delete
array(
[1299] Fix | Delete
'%ver <=',
[1300] Fix | Delete
'%ver <',
[1301] Fix | Delete
'%ver >=',
[1302] Fix | Delete
'%ver >',
[1303] Fix | Delete
),
[1304] Fix | Delete
$wp_styles->registered[ $handle ]->extra['conditional']
[1305] Fix | Delete
);
[1306] Fix | Delete
[1307] Fix | Delete
// Next, replace any !IE checks. These shouldn't be present since WP's conditional stylesheet implementation doesn't support them, but someone could be _doing_it_wrong().
[1308] Fix | Delete
$style_data['conditional'] = preg_replace( '#!\s*IE(\s*\d+){0}#i', '1==2', $style_data['conditional'] );
[1309] Fix | Delete
[1310] Fix | Delete
// Lastly, remove the IE strings
[1311] Fix | Delete
$style_data['conditional'] = str_replace( 'IE', '', $style_data['conditional'] );
[1312] Fix | Delete
}
[1313] Fix | Delete
[1314] Fix | Delete
// Parse requested media context for stylesheet
[1315] Fix | Delete
if ( isset( $wp_styles->registered[ $handle ]->args ) ) {
[1316] Fix | Delete
$style_data['media'] = esc_attr( $wp_styles->registered[ $handle ]->args );
[1317] Fix | Delete
}
[1318] Fix | Delete
[1319] Fix | Delete
// Add stylesheet to data that will be returned to IS JS
[1320] Fix | Delete
array_push( $results['styles'], $style_data );
[1321] Fix | Delete
}
[1322] Fix | Delete
}
[1323] Fix | Delete
}
[1324] Fix | Delete
[1325] Fix | Delete
// Expose additional stylesheet data to filters, but only include in final `$results` array if needed.
[1326] Fix | Delete
if ( ! isset( $results['styles'] ) ) {
[1327] Fix | Delete
$results['styles'] = array();
[1328] Fix | Delete
}
[1329] Fix | Delete
[1330] Fix | Delete
/**
[1331] Fix | Delete
* Filter the additional styles required by the latest set of IS posts.
[1332] Fix | Delete
*
[1333] Fix | Delete
* @module infinite-scroll
[1334] Fix | Delete
*
[1335] Fix | Delete
* @since 2.1.2
[1336] Fix | Delete
*
[1337] Fix | Delete
* @param array $results['styles'] Additional styles required by the latest set of IS posts.
[1338] Fix | Delete
* @param array|bool $initial_styles Set of styles loaded on each page.
[1339] Fix | Delete
* @param array $results Array of Infinite Scroll results.
[1340] Fix | Delete
* @param array $query_args Array of Query arguments.
[1341] Fix | Delete
* @param WP_Query $wp_query WP Query.
[1342] Fix | Delete
*/
[1343] Fix | Delete
$results['styles'] = apply_filters(
[1344] Fix | Delete
'infinite_scroll_additional_stylesheets',
[1345] Fix | Delete
$results['styles'],
[1346] Fix | Delete
$initial_styles,
[1347] Fix | Delete
$results,
[1348] Fix | Delete
$query_args,
[1349] Fix | Delete
$wp_query
[1350] Fix | Delete
);
[1351] Fix | Delete
[1352] Fix | Delete
if ( empty( $results['styles'] ) ) {
[1353] Fix | Delete
unset( $results['styles'] );
[1354] Fix | Delete
}
[1355] Fix | Delete
[1356] Fix | Delete
// Lastly, return the IS results array
[1357] Fix | Delete
return $results;
[1358] Fix | Delete
}
[1359] Fix | Delete
[1360] Fix | Delete
/**
[1361] Fix | Delete
* Runs the query and returns the results via JSON.
[1362] Fix | Delete
* Triggered by an AJAX request.
[1363] Fix | Delete
*
[1364] Fix | Delete
* @global $wp_query
[1365] Fix | Delete
* @global $wp_the_query
[1366] Fix | Delete
* @uses current_theme_supports, get_option, self::wp_query, current_user_can, apply_filters, self::get_settings, add_filter, WP_Query, remove_filter, have_posts, wp_head, do_action, add_action, this::render, this::has_wrapper, esc_attr, wp_footer, sharing_register_post_for_share_counts, get_the_id
[1367] Fix | Delete
*/
[1368] Fix | Delete
public function query() {
[1369] Fix | Delete
if ( ! isset( $_REQUEST['page'] ) || ! current_theme_supports( 'infinite-scroll' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes to the site.
[1370] Fix | Delete
die( 0 );
[1371] Fix | Delete
}
[1372] Fix | Delete
[1373] Fix | Delete
// @todo see if we should validate this nonce since we use it to form a query.
[1374] Fix | Delete
$page = (int) $_REQUEST['page']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- we're casting this to an int and not making changes to the site.
[1375] Fix | Delete
[1376] Fix | Delete
// Sanitize and set $previousday. Expected format: dd.mm.yy
[1377] Fix | Delete
if ( isset( $_REQUEST['currentday'] ) && is_string( $_REQUEST['currentday'] ) && preg_match( '/^\d{2}\.\d{2}\.\d{2}$/', $_REQUEST['currentday'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput, WordPress.Security.NonceVerification.Recommended -- manually validating, no changes to site
[1378] Fix | Delete
global $previousday;
[1379] Fix | Delete
$previousday = $_REQUEST['currentday']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
[1380] Fix | Delete
}
[1381] Fix | Delete
[1382] Fix | Delete
$post_status = array( 'publish' );
[1383] Fix | Delete
if ( current_user_can( 'read_private_posts' ) ) {
[1384] Fix | Delete
array_push( $post_status, 'private' );
[1385] Fix | Delete
}
[1386] Fix | Delete
[1387] Fix | Delete
$order = isset( $_REQUEST['order'] ) && in_array( $_REQUEST['order'], array( 'ASC', 'DESC' ), true ) ? sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) : 'DESC'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
[1388] Fix | Delete
[1389] Fix | Delete
$query_args = array_merge(
[1390] Fix | Delete
self::wp_query()->query_vars,
[1391] Fix | Delete
array(
[1392] Fix | Delete
'paged' => $page,
[1393] Fix | Delete
'post_status' => $post_status,
[1394] Fix | Delete
'posts_per_page' => self::posts_per_page(), // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
[1395] Fix | Delete
'order' => $order,
[1396] Fix | Delete
)
[1397] Fix | Delete
);
[1398] Fix | Delete
[1399] Fix | Delete
// 4.0 ?s= compatibility, see https://core.trac.wordpress.org/ticket/11330#comment:50
[1400] Fix | Delete
if ( empty( $query_args['s'] ) && ! isset( self::wp_query()->query['s'] ) ) {
[1401] Fix | Delete
unset( $query_args['s'] );
[1402] Fix | Delete
}
[1403] Fix | Delete
[1404] Fix | Delete
// By default, don't query for a specific page of a paged post object.
[1405] Fix | Delete
// This argument can come from merging self::wp_query() into $query_args above.
[1406] Fix | Delete
// Since IS is only used on archives, we should always display the first page of any paged content.
[1407] Fix | Delete
unset( $query_args['page'] );
[1408] Fix | Delete
[1409] Fix | Delete
/**
[1410] Fix | Delete
* Filter the array of main query arguments.
[1411] Fix | Delete
*
[1412] Fix | Delete
* @module infinite-scroll
[1413] Fix | Delete
*
[1414] Fix | Delete
* @since 2.0.1
[1415] Fix | Delete
*
[1416] Fix | Delete
* @param array $query_args Array of Query arguments.
[1417] Fix | Delete
*/
[1418] Fix | Delete
$query_args = apply_filters( 'infinite_scroll_query_args', $query_args );
[1419] Fix | Delete
[1420] Fix | Delete
add_filter( 'posts_where', array( $this, 'query_time_filter' ), 10, 2 );
[1421] Fix | Delete
[1422] Fix | Delete
$infinite_scroll_query = new WP_Query();
[1423] Fix | Delete
$GLOBALS['wp_the_query'] = $infinite_scroll_query;
[1424] Fix | Delete
$GLOBALS['wp_query'] = $infinite_scroll_query;
[1425] Fix | Delete
[1426] Fix | Delete
$infinite_scroll_query->query( $query_args );
[1427] Fix | Delete
[1428] Fix | Delete
remove_filter( 'posts_where', array( $this, 'query_time_filter' ), 10 );
[1429] Fix | Delete
[1430] Fix | Delete
$results = array();
[1431] Fix | Delete
[1432] Fix | Delete
if ( have_posts() ) {
[1433] Fix | Delete
// Fire wp_head to ensure that all necessary scripts are enqueued. Output isn't used, but scripts are extracted in self::action_wp_footer.
[1434] Fix | Delete
ob_start();
[1435] Fix | Delete
wp_head();
[1436] Fix | Delete
while ( ob_get_length() ) {
[1437] Fix | Delete
ob_end_clean();
[1438] Fix | Delete
}
[1439] Fix | Delete
[1440] Fix | Delete
$results['type'] = 'success';
[1441] Fix | Delete
[1442] Fix | Delete
/**
[1443] Fix | Delete
* Fires when rendering Infinite Scroll posts.
[1444] Fix | Delete
*
[1445] Fix | Delete
* @module infinite-scroll
[1446] Fix | Delete
*
[1447] Fix | Delete
* @since 2.0.0
[1448] Fix | Delete
*/
[1449] Fix | Delete
do_action( 'infinite_scroll_render' );
[1450] Fix | Delete
$results['html'] = ob_get_clean();
[1451] Fix | Delete
if ( empty( $results['html'] ) ) {
[1452] Fix | Delete
/**
[1453] Fix | Delete
* Gather renderer callbacks. These will be called in order and allow multiple callbacks to be queued. Once content is found, no futher callbacks will run.
[1454] Fix | Delete
*
[1455] Fix | Delete
* @module infinite-scroll
[1456] Fix | Delete
*
[1457] Fix | Delete
* @since 6.0.0
[1458] Fix | Delete
*/
[1459] Fix | Delete
$callbacks = apply_filters(
[1460] Fix | Delete
'infinite_scroll_render_callbacks',
[1461] Fix | Delete
array( self::get_settings()->render ) // This is the setting callback e.g. from add theme support.
[1462] Fix | Delete
);
[1463] Fix | Delete
[1464] Fix | Delete
// Append fallback callback. That rhymes.
[1465] Fix | Delete
$callbacks[] = array( $this, 'render' );
[1466] Fix | Delete
[1467] Fix | Delete
foreach ( $callbacks as $callback ) {
[1468] Fix | Delete
if ( false !== $callback && is_callable( $callback ) ) {
[1469] Fix | Delete
rewind_posts();
[1470] Fix | Delete
ob_start();
[1471] Fix | Delete
[1472] Fix | Delete
add_action( 'infinite_scroll_render', $callback );
[1473] Fix | Delete
[1474] Fix | Delete
/**
[1475] Fix | Delete
* This action is already documented above.
[1476] Fix | Delete
* See https://github.com/Automattic/jetpack/pull/16317/
[1477] Fix | Delete
* for more details as to why it was introduced.
[1478] Fix | Delete
*/
[1479] Fix | Delete
do_action( 'infinite_scroll_render' );
[1480] Fix | Delete
[1481] Fix | Delete
// Fire wp_head to ensure that all necessary scripts are enqueued. Output isn't used, but scripts are extracted in self::action_wp_footer.
[1482] Fix | Delete
wp_head();
[1483] Fix | Delete
[1484] Fix | Delete
$results['html'] = ob_get_clean();
[1485] Fix | Delete
remove_action( 'infinite_scroll_render', $callback );
[1486] Fix | Delete
}
[1487] Fix | Delete
if ( ! empty( $results['html'] ) ) {
[1488] Fix | Delete
break;
[1489] Fix | Delete
}
[1490] Fix | Delete
}
[1491] Fix | Delete
}
[1492] Fix | Delete
[1493] Fix | Delete
// If primary and fallback rendering methods fail, prevent further IS rendering attempts. Otherwise, wrap the output if requested.
[1494] Fix | Delete
if ( empty( $results['html'] ) ) {
[1495] Fix | Delete
unset( $results['html'] );
[1496] Fix | Delete
/**
[1497] Fix | Delete
* Fires when Infinite Scoll doesn't render any posts.
[1498] Fix | Delete
*
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function