Changeset 3550 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php
- Timestamp:
- 06/22/2016 02:49:08 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php
r3542 r3550 248 248 249 249 // ES API does not allow more than 15 results at a time 250 if ( $posts_per_page > 15)251 $posts_per_page = 15;250 if ( $posts_per_page > 200 ) 251 $posts_per_page = 200; 252 252 253 253 $date_cutoff = strftime( '%Y-%m-%d', strtotime( '-2 years' ) ); 254 254 $date_today = strftime( '%Y-%m-%d' ); 255 255 $version_cutoff = ( defined('WP_CORE_STABLE_BRANCH') ? sprintf( '%0.1f', WP_CORE_STABLE_BRANCH - 0.5) : '4.0' ); 256 257 // If the request comes from WordPress and the major version string looks sane, use a more specific version constraint 258 if ( preg_match( '|WordPress/(\d+[.]\d+)|', $_SERVER['HTTP_USER_AGENT'], $matches ) ) { 259 if ( $matches[1] >= $version_cutoff && $matches[1] <= WP_CORE_STABLE_BRANCH ) { 260 $version_cutoff = sprintf( '%0.1f', $matches[1] - 0.2 ); 261 } 262 } 256 263 257 264 // Start building the WP-style search query args … … 272 279 ); 273 280 281 if ( defined( 'WPORG_IS_API' ) && WPORG_IS_API ) { 282 // Look for plugins excluding those already installed 283 if ( isset( $query->query['installed_plugins'] ) ) { 284 $es_wp_query_args['filters'][] = array( 'not' => array( 'terms' => array( 'slug' => $query->query['installed_plugins'] ) ) ); 285 } 286 } 287 274 288 $locale = get_locale(); 275 289 if ( $locale && $locale !== 'en' && $locale !== 'en_US' ) { … … 327 341 328 342 public function action__pre_get_posts( $query ) { 343 // Treat an API request for the recommended tab as a search, even though there is no search string in the query 344 if ( defined( 'WPORG_IS_API' ) && WPORG_IS_API && isset( $query->query['browse'] ) && $query->query['browse'] === 'recommended' ) 345 $query->is_search = true; 346 329 347 if ( ! $query->is_main_query() || ! $query->is_search() ) 330 348 return; … … 610 628 } 611 629 } else { 630 $query = array( 'match_all' => array() ); 631 $es_query_args['query'] = Jetpack_Search::score_query_by_recency( $query ); 612 632 if ( ! $args['orderby'] ) { 613 633 $args['orderby'] = array( 'date' );
Note: See TracChangeset
for help on using the changeset viewer.