/**
* Retrieves a collection of search results.
*
* @since 5.0.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function get_items( $request ) { $handler =
$this->
get_search_handler( $request );
if ( is_wp_error( $handler ) ) { return $handler;
} $result =
$handler->
search_items( $request );
if ( !
isset( $result[ WP_REST_Search_Handler::RESULT_IDS
] ) || !
is_array( $result[ WP_REST_Search_Handler::RESULT_IDS
] ) || !
isset( $result[ WP_REST_Search_Handler::RESULT_TOTAL
] ) ) { return new WP_Error( 'rest_search_handler_error',
__( 'Internal search handler error.'
),
array
( 'status' => 500
) );