Adds wp_query_params to missing endpoints. Replaces author_id by just author on mapping.

This commit is contained in:
Mateus Machado Luna 2019-10-21 12:18:36 -03:00
parent 88ca241401
commit c18a0c817e
8 changed files with 36 additions and 10 deletions

View File

@ -66,7 +66,7 @@ class REST_Controller extends \WP_REST_Controller {
'name' => 'title',
'title' => 'title',
'id' => 'p',
'authorid' => 'author_id',
'authorid' => 'author',
'authorname' => 'author_name',
'search' => 's',
'searchterm' => 'search',

View File

@ -43,7 +43,7 @@ class REST_Collections_Controller extends REST_Controller {
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => $this->get_wp_query_params(),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
),
array(
'methods' => \WP_REST_Server::CREATABLE,
@ -58,7 +58,7 @@ class REST_Collections_Controller extends REST_Controller {
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item'),
'permission_callback' => array($this, 'get_item_permissions_check'),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
'args' => $this->get_wp_query_params(),
),
array(

View File

@ -474,6 +474,10 @@ class REST_Filters_Controller extends REST_Controller {
'default' => 'view',
'items' => array( 'view, edit' )
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params()
);
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
$map = $this->filter_repository->get_map();

View File

@ -56,7 +56,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => $this->get_wp_query_params(),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
)
)
);
@ -268,7 +268,17 @@ class REST_Item_Metadata_Controller extends REST_Controller {
public function get_endpoint_args_for_item_schema( $method = null ) {
$endpoint_args = [];
if ($method === \WP_REST_Server::EDITABLE) {
if($method === \WP_REST_Server::READABLE) {
$endpoint_args['context'] = array(
'type' => 'string',
'default' => 'view',
'items' => array( 'view, edit' )
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params()
);
} elseif ($method === \WP_REST_Server::EDITABLE) {
$endpoint_args['values'] = [
'type' => 'array/string/object/integer',
'items' => [

View File

@ -356,6 +356,10 @@ class REST_Logs_Controller extends REST_Controller {
'default' => 'view',
'items' => array( 'view' )
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params()
);
}
return $endpoint_args;

View File

@ -569,6 +569,10 @@ class REST_Metadata_Controller extends REST_Controller {
'default' => 'view',
'items' => array( 'view, edit' )
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params()
);
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
$map = $this->metadatum_repository->get_map();

View File

@ -452,16 +452,16 @@ class REST_Taxonomies_Controller extends REST_Controller {
public function get_endpoint_args_for_item_schema( $method = null ) {
$endpoint_args = [];
if($method === \WP_REST_Server::READABLE) {
$endpoint_args['fetch_only'] = array(
'type' => 'string/array',
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.' ),
);
$endpoint_args['context'] = array(
'type' => 'string',
'default' => 'view',
'items' => array( 'view, edit' )
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params(),
parent::get_fetch_only_param()
);
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
$map = $this->taxonomy_repository->get_map();

View File

@ -425,6 +425,10 @@ class REST_Terms_Controller extends REST_Controller {
'default' => 'view',
'items' => array( 'view, edit' )
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params()
);
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
$map = $this->terms_repository->get_map();