REST API: Make all collection params filterable.

For developers wanting to add their own registered collection parameters, they can now use the `rest_$type_collection_params` filter. This brings consistency with the already existing `rest_$post_type_collection_params`.

Fixes #38710.
Props jnylen0.

Built from https://develop.svn.wordpress.org/trunk@39223


git-svn-id: http://core.svn.wordpress.org/trunk@39163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe Hoyle 2016-11-14 16:42:31 +00:00
parent 5c90d9ed8e
commit a4fa8c528f
4 changed files with 41 additions and 4 deletions

View File

@ -1389,7 +1389,18 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
'validate_callback' => 'rest_validate_request_arg',
);
return $query_params;
/**
* Filter collection parameters for the comments controller.
*
* This filter registers the collection parameter, but does not map the
* collection parameter to an internal WP_Comment_Query parameter. Use the
* `rest_comment_query` filter to set WP_Comment_Query parameters.
*
* @since 4.7.0
*
* @param $params JSON Schema-formatted collection parameters.
*/
return apply_filters( 'rest_comment_collection_params', $query_params );
}
/**

View File

@ -959,7 +959,22 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
'type' => 'string',
);
return $query_params;
/**
* Filter collection parameters for the terms controller.
*
* The dynamic part of the filter `$this->taxonomy` refers to the taxonomy
* slug for the controller.
*
* This filter registers the collection parameter, but does not map the
* collection parameter to an internal WP_Term_Query parameter. Use the
* `rest_{$this->taxonomy}_query` filter to set WP_Term_Query parameters.
*
* @since 4.7.0
*
* @param $params JSON Schema-formatted collection parameters.
* @param WP_Taxonomy $taxonomy_obj Taxonomy object.
*/
return apply_filters( 'rest_{$this->taxonomy}_collection_params', $query_params, $taxonomy );
}
/**

View File

@ -1298,6 +1298,17 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
);
return $query_params;
/**
* Filter collection parameters for the users controller.
*
* This filter registers the collection parameter, but does not map the
* collection parameter to an internal WP_User_Query parameter. Use the
* `rest_user_query` filter to set WP_User_Query arguments.
*
* @since 4.7.0
*
* @param $params JSON Schema-formatted collection parameters.
*/
return apply_filters( 'rest_user_collection_params', $query_params );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta3-39222';
$wp_version = '4.7-beta3-39223';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.