REST API: Introduce `rest_post_search_query` filter.

This filter allows the query arguments to be manipulated for a post search query in the REST API.

Props Chouby, swissspidy.
Fixes #45454.
Built from https://develop.svn.wordpress.org/trunk@44482


git-svn-id: http://core.svn.wordpress.org/trunk@44313 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2019-01-08 21:45:48 +00:00
parent f510ab9e94
commit cd7b916d55
2 changed files with 13 additions and 1 deletions

View File

@ -68,6 +68,18 @@ class WP_REST_Post_Search_Handler extends WP_REST_Search_Handler {
$query_args['s'] = $request['search']; $query_args['s'] = $request['search'];
} }
/**
* Filters the query arguments for a search request.
*
* Enables adding extra arguments or setting defaults for a post search request.
*
* @since 5.1.0
*
* @param array $query_args Key value array of query var to query value.
* @param WP_REST_Request $request The request used.
*/
$query_args = apply_filters( 'rest_post_search_query', $query_args, $request );
$query = new WP_Query(); $query = new WP_Query();
$found_ids = $query->query( $query_args ); $found_ids = $query->query( $query_args );
$total = $query->found_posts; $total = $query->found_posts;

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44481'; $wp_version = '5.1-alpha-44482';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.