Merge pull request #21562 from terence1990/feature/rest-api-crud-params-filter

Add a filter to WC_REST_CRUD_Controller::get_collection_params method to allow developers to change params
This commit is contained in:
Mike Jolley 2019-01-16 11:32:03 +00:00 committed by GitHub
commit 50a86a1a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -609,6 +609,19 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
); );
} }
return $params; /**
* Filter collection parameters for the posts controller.
*
* The dynamic part of the filter `$this->post_type` refers to the post
* type slug for the controller.
*
* This filter registers the collection parameter, but does not map the
* collection parameter to an internal WP_Query parameter. Use the
* `rest_{$this->post_type}_query` filter to set WP_Query parameters.
*
* @param array $query_params JSON Schema-formatted collection parameters.
* @param WP_Post_Type $post_type Post type object.
*/
return apply_filters( "rest_{$this->post_type}_collection_params", $params, $this->post_type );
} }
} }