@@ 480-499 (lines=20) @@ | ||
477 | */ |
|
478 | do_action( 'did_jetpack_search_query', $query ); |
|
479 | ||
480 | if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) { |
|
481 | /** |
|
482 | * Fires after a search query request has failed |
|
483 | * |
|
484 | * @module search |
|
485 | * |
|
486 | * @since 5.6.0 |
|
487 | * |
|
488 | * @param array Array containing the response code and response from the failed search query |
|
489 | */ |
|
490 | do_action( |
|
491 | 'failed_jetpack_search_query', |
|
492 | array( |
|
493 | 'response_code' => $response_code, |
|
494 | 'json' => $response, |
|
495 | ) |
|
496 | ); |
|
497 | ||
498 | return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code ); |
|
499 | } |
|
500 | ||
501 | return $response; |
|
502 | } |
@@ 299-318 (lines=20) @@ | ||
296 | $response_code = wp_remote_retrieve_response_code( $request ); |
|
297 | $response = json_decode( wp_remote_retrieve_body( $request ), true ); |
|
298 | ||
299 | if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) { |
|
300 | /** |
|
301 | * Fires after a search query request has failed |
|
302 | * |
|
303 | * @module search |
|
304 | * |
|
305 | * @since 5.6.0 |
|
306 | * |
|
307 | * @param array Array containing the response code and response from the failed search query |
|
308 | */ |
|
309 | do_action( |
|
310 | 'failed_jetpack_search_query', |
|
311 | array( |
|
312 | 'response_code' => $response_code, |
|
313 | 'json' => $response, |
|
314 | ) |
|
315 | ); |
|
316 | ||
317 | return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code ); |
|
318 | } |
|
319 | ||
320 | $took = is_array( $response ) && ! empty( $response['took'] ) |
|
321 | ? $response['took'] |