Changeset 12942
- Timestamp:
- 10/11/2023 09:49:06 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-search.php
r12362 r12942 67 67 68 68 // add_filter( 'jetpack_search_abort', array( $this, 'log_jetpack_search_abort' ) ); 69 69 70 70 // $es_query_args = apply_filters( 'jetpack_search_es_query_args', $es_query_args, $query ); 71 71 72 72 add_filter( 'jetpack_search_es_wp_query_args', array( $this, 'jetpack_search_es_wp_query_args' ), 10, 2 ); 73 add_filter( 'jetpack_search_es_query_args', array( $this, 'jetpack_search_es_query_args' ), 10, 2 ); 73 add_filter( 'jetpack_search_es_query_args', array( $this, 'jetpack_search_es_query_args' ), 10, 2 ); 74 add_filter( 'posts_pre_query', array( $this, 'set_max_num_pages' ), 15, 2 ); // After `Classic_Search::filter__posts_pre_query()` 74 75 75 76 // Load Jetpack Search. … … 82 83 } else { 83 84 // Old(er) Jetpack, load the classic search module, Temporarily. 84 85 85 86 include_once WP_PLUGIN_DIR . '/jetpack/modules/search/class.jetpack-search.php'; 86 87 include_once WP_PLUGIN_DIR . '/jetpack/modules/search/class.jetpack-search-helpers.php'; … … 396 397 } 397 398 399 /** 400 * Limit the number of pagination links to 50. 401 * 402 * Jetpack ignores the `max_num_pages` that's set in `WP_Query` args and overrides it in 403 * `Classic_Search::filter__posts_pre_query()`. When there are more than 1,000 matches, their value causes 404 * Core's `paginate_links()` to generated 51 links, even though we redirect the user to the homepage when 405 * page 51+ is requested. 406 */ 407 function set_max_num_pages( $posts, $query ) { 408 $post_type = (array) $query->query_vars['post_type'] ?? ''; 409 410 if ( is_admin() || ! is_search() || ! in_array( 'plugin', $post_type ) ) { 411 return $posts; 412 } 413 414 if ( $query->max_num_pages > 50 ) { 415 $query->max_num_pages = 50; 416 } 417 418 return $posts; 419 } 420 398 421 public function log_search_es_wp_query_args( $es_wp_query_args, $query ) { 399 422 error_log( '--- ' . __FUNCTION__ . ' ---' );
Note: See TracChangeset
for help on using the changeset viewer.