WP_REST_Search_Controller::__construct( array $search_handlers )
In this article
Constructor.
Parameters
$search_handlersarrayrequired- List of search handlers to use in the controller. Each search handler instance must extend the
WP_REST_Search_Handlerclass.
Source
public function __construct( array $search_handlers ) {
$this->namespace = 'wp/v2';
$this->rest_base = 'search';
foreach ( $search_handlers as $search_handler ) {
if ( ! $search_handler instanceof WP_REST_Search_Handler ) {
_doing_it_wrong(
__METHOD__,
/* translators: %s: PHP class name. */
sprintf( __( 'REST search handlers must extend the %s class.' ), 'WP_REST_Search_Handler' ),
'5.0.0'
);
continue;
}
$this->search_handlers[ $search_handler->get_type() ] = $search_handler;
}
}
Related
| Uses | Description |
|---|---|
__()wp-includes/l10n.php | Retrieves the translation of $text. |
_doing_it_wrong()wp-includes/functions.php | Marks something as being incorrectly called. |
| Used by | Description |
|---|---|
create_initial_rest_routes()wp-includes/rest-api.php | Registers default REST API routes. |
Changelog
| Version | Description |
|---|---|
| 5.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
