diff options
Diffstat (limited to 'plugins/jetpack/modules/search/class.jetpack-search.php')
-rw-r--r-- | plugins/jetpack/modules/search/class.jetpack-search.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/jetpack/modules/search/class.jetpack-search.php b/plugins/jetpack/modules/search/class.jetpack-search.php index 5908bd61..62909e91 100644 --- a/plugins/jetpack/modules/search/class.jetpack-search.php +++ b/plugins/jetpack/modules/search/class.jetpack-search.php @@ -333,15 +333,15 @@ class Jetpack_Search { $do_authenticated_request = false; if ( class_exists( 'Jetpack_Client' ) && - isset( $es_args['authenticated_request'] ) && - true === $es_args['authenticated_request'] ) { + isset( $es_args['authenticated_request'] ) && + true === $es_args['authenticated_request'] ) { $do_authenticated_request = true; } unset( $es_args['authenticated_request'] ); $request_args = array( - 'headers' => array( + 'headers' => array( 'Content-Type' => 'application/json', ), 'timeout' => 10, @@ -371,7 +371,8 @@ class Jetpack_Search { } $response_code = wp_remote_retrieve_response_code( $request ); - $response = json_decode( wp_remote_retrieve_body( $request ), true ); + + $response = json_decode( wp_remote_retrieve_body( $request ), true ); $took = is_array( $response ) && ! empty( $response['took'] ) ? $response['took'] @@ -499,6 +500,10 @@ class Jetpack_Search { * @param WP_Query $query The original WP_Query to use for the parameters of our search. */ public function do_search( WP_Query $query ) { + if ( ! $query->is_main_query() || ! $query->is_search() ) { + return; + } + $page = ( $query->get( 'paged' ) ) ? absint( $query->get( 'paged' ) ) : 1; // Get maximum allowed offset and posts per page values for the API. @@ -716,7 +721,6 @@ class Jetpack_Search { return $sanitized_post_types; } - /** * Get the Elasticsearch result. * @@ -1113,6 +1117,7 @@ class Jetpack_Search { unset( $es_query_args['sort'] ); } + // Aggregations if ( ! empty( $args['aggregations'] ) ) { $this->add_aggregations_to_es_query_builder( $args['aggregations'], $parser ); } |