REST API: Introduce search term handler.

This allows for clients to search the available terms via the `/wp/v2/search` endpoint by using a `type=term` query parameter.

Fixes #51458.
Props andraganescu, zieladam, noisysocks, TimothyBlynJacobs.


git-svn-id: https://develop.svn.wordpress.org/trunk@49103 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs
2020-10-08 01:30:25 +00:00
parent b7b1584139
commit 5b6f5f9f6d
5 changed files with 354 additions and 2 deletions
+6 -1
View File
@@ -268,6 +268,11 @@ function create_initial_rest_routes() {
$controller = new WP_REST_Comments_Controller;
$controller->register_routes();
$search_handlers = array(
new WP_REST_Post_Search_Handler(),
new WP_REST_Term_Search_Handler(),
);
/**
* Filters the search handlers to use in the REST search controller.
*
@@ -277,7 +282,7 @@ function create_initial_rest_routes() {
* handler instance must extend the `WP_REST_Search_Handler` class.
* Default is only a handler for posts.
*/
$search_handlers = apply_filters( 'wp_rest_search_handlers', array( new WP_REST_Post_Search_Handler() ) );
$search_handlers = apply_filters( 'wp_rest_search_handlers', $search_handlers );
$controller = new WP_REST_Search_Controller( $search_handlers );
$controller->register_routes();