Ticket #496: 496.diff
File 496.diff, 1.6 KB (added by , 8 years ago) |
---|
-
wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
35 35 add_filter( 'post_type_link', array( $this, 'filter_post_type_link' ), 10, 2 ); 36 36 add_filter( 'term_link', array( $this, 'filter_term_link' ), 10, 2 ); 37 37 add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 38 add_filter( 'found_posts', array( $this, 'filter_found_posts' ), 10, 2 ); 38 39 add_filter( 'rest_api_allowed_post_types', array( $this, 'filter_allowed_post_types' ) ); 39 40 add_filter( 'pre_update_option_jetpack_options', array( $this, 'filter_jetpack_options' ) ); 40 41 add_action( 'template_redirect', array( $this, 'prevent_canonical_for_plugins' ), 9 ); … … 795 796 } 796 797 797 798 /** 799 * Filter to limit the total number of found posts in browse queries. 800 * Stops search crawlers from paginating through the entire DB. 801 */ 802 public function filter_found_posts( $found_posts, $wp_query ) { 803 if ( isset( $wp_query->query['browse'] ) && in_array( 'plugin', $wp_query->query_vars['post_type'] ) ) { 804 return min( $found_posts, 99 * $wp_query->query_vars['posts_per_page'] ); // 99 pages 805 } 806 807 return $found_posts; 808 } 809 810 /** 798 811 * Filter to bypass caching for options critical to Jetpack sync to work around race conditions and other unidentified bugs. 799 812 * If this works and becomes a permanent solution, it probably belongs elsewhere. 800 813 */