__( 'Internal search handler error.'
),
array
( 'status' => 500
) );
} $ids =
$result[ WP_REST_Search_Handler::RESULT_IDS
];
$results = array
();
foreach ( $ids as $id ) { $data =
$this->
prepare_item_for_response( $id,
$request );
$results[] =
$this->
prepare_response_for_collection( $data );
} $total =
(int) $result[ WP_REST_Search_Handler::RESULT_TOTAL
];
$page =
(int) $request['page'
];
$per_page =
(int) $request['per_page'
];
$max_pages =
ceil( $total /
$per_page );
if ( $page >
$max_pages &&
$total > 0
) { return new WP_Error( 'rest_search_invalid_page_number',
__( 'The page number requested is larger than the number of pages available.'
),