Merge branch 'release/0.13' of https://github.com/tainacan/tainacan into release/0.13

This commit is contained in:
vnmedeiros 2019-10-22 00:03:03 -03:00
commit 0ce1bc3e8e
9 changed files with 136 additions and 40 deletions

View File

@ -295,9 +295,10 @@ class REST_Controller extends \WP_REST_Controller {
);
$query_params['context'] = array(
'type' => 'string',
'default' => 'view',
'enum' => array(
'type' => 'string',
'default' => 'view',
'description' => 'The context in which the request is made.',
'enum' => array(
'view',
'edit'
),
@ -341,7 +342,7 @@ class REST_Controller extends \WP_REST_Controller {
'description' => __( 'Order sort attribute ascending or descending.', 'tainacan' ),
'type' => 'string/array',
'default' => 'desc',
'enum' => array( 'asc', 'desc' ),
'enum' => array( 'asc', 'desc', 'ASC', 'DESC' ),
);
$query_params['orderby'] = array(
@ -399,8 +400,26 @@ class REST_Controller extends \WP_REST_Controller {
),
'metacompare' => array(
'type' => 'string',
'description' => __('Operator to test the meta_value. Possible values are =, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, NOT EXISTS, REGEXP, NOT REGEXP or RLIKE.'),
'description' => __('Operator to test the metavalue'),
'default' => '=',
'enum' => array(
'=',
'!=',
'>',
'>=',
'<',
'<=',
'LIKE',
'NOT LIKE',
'IN',
'NOT IN',
'BETWEEN',
'NOT BETWEEN',
'NOT EXISTS',
'REGEXP',
'NOT REGEXP',
'RLIKE'
)
),
'metaquery' => array(
'description' => __('Limits result set to items that have specific custom metadata'),
@ -418,8 +437,24 @@ class REST_Controller extends \WP_REST_Controller {
),
'compare' => array(
'type' => 'string',
'description' => __('Operator to test. Possible values are =, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, EXISTS and NOT EXISTS.'),
'default' => '='
'description' => __('Operator to test.'),
'default' => '=',
'enum' => array(
'=',
'!=',
'>',
'>=',
'<',
'<=',
'LIKE',
'NOT LIKE',
'IN',
'NOT IN',
'BETWEEN',
'NOT BETWEEN',
'EXISTS',
'NOT EXISTS'
)
),
'relation' => array(
'type' => 'string',
@ -469,8 +504,24 @@ class REST_Controller extends \WP_REST_Controller {
),
'compare' => array(
'type' => 'string',
'description' => __('Operator to test. Possible values are =, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, EXISTS and NOT EXISTS.'),
'default' => '='
'description' => __('Operator to test.'),
'default' => '=',
'enum' => array(
'=',
'!=',
'>',
'>=',
'<',
'<=',
'LIKE',
'NOT LIKE',
'IN',
'NOT IN',
'BETWEEN',
'NOT BETWEEN',
'EXISTS',
'NOT EXISTS'
)
),
'dayofweek' => array('type' => 'array'),
'inclusive' => array(
@ -500,7 +551,14 @@ class REST_Controller extends \WP_REST_Controller {
),
'metadatum' => array(
'type' => 'string',
'description' => __('Select taxonomy term by. Possible values are term_id, name, slug or term_taxonomy_id. Default value is term_id.')
'default' => 'term_id',
'description' => __('Select taxonomy term by'),
'enum' => array(
'term_id',
'name',
'slug',
'term_taxonomy_id'
)
),
'terms' => array(
'type' => 'int/string/array',
@ -508,13 +566,24 @@ class REST_Controller extends \WP_REST_Controller {
),
'operator' => array(
'type' => 'string',
'description' => __('Operator to test. Possible values are IN, NOT IN, AND, EXISTS and NOT EXISTS'),
'default' => 'IN'
'description' => __('Operator to test.'),
'default' => 'IN',
'enum' => array(
'IN',
'NOT IN',
'AND',
'EXISTS',
'NOT EXISTS'
)
),
'relation' => array(
'type' => 'string',
'description' => __('The logical relationship between each inner taxonomy array when there is more than one. Possible values are AND, OR. Do not use with a single inner taxonomy array.'),
'default' => 'AND'
'description' => __('The logical relationship between each inner taxonomy array when there is more than one. Do not use with a single inner taxonomy array.'),
'default' => 'AND',
'enum' => array(
'AND',
'OR'
)
),
),
'type' => 'array'

View File

@ -73,8 +73,8 @@ class REST_Collections_Controller extends REST_Controller {
'permission_callback' => array($this, 'delete_item_permissions_check'),
'args' => array(
'permanently' => array(
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
'default' => 'false'
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
'default' => '0',
),
)
),

View File

@ -83,8 +83,8 @@ class REST_Filters_Controller extends REST_Controller {
'permission_callback' => array($this, 'delete_item_permissions_check'),
'args' => array(
'permanently' => array(
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
'default' => 'false'
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
'default' => '0'
),
)
),
@ -497,16 +497,17 @@ class REST_Filters_Controller extends REST_Controller {
* @return array|void
*/
public function get_wp_query_params() {
$query_params['context']['default'] = 'view';
$query_params = array_merge($query_params, parent::get_wp_query_params());
$query_params['name'] = array(
'description' => __('Limits the result set to filters with a specific name'),
'type' => 'string',
);
$query_params = array_merge($query_params, parent::get_meta_queries_params());
$query_params = array_merge(
$query_params,
parent::get_wp_query_params(),
parent::get_meta_queries_params()
);
return $query_params;
}

View File

@ -270,8 +270,8 @@ class REST_Item_Metadata_Controller extends REST_Controller {
if($method === \WP_REST_Server::READABLE) {
$endpoint_args = array_merge(
$endpoint_args,
parent::get_wp_query_params()
$endpoint_args,
$this->get_wp_query_params()
);
} elseif ($method === \WP_REST_Server::EDITABLE) {
$endpoint_args['values'] = [
@ -295,7 +295,15 @@ class REST_Item_Metadata_Controller extends REST_Controller {
* @return array
*/
public function get_wp_query_params() {
$query_params['context']['default'] = 'view';
$query_params['context'] = array(
'type' => 'string',
'default' => 'view',
'description' => 'The context in which the request is made.',
'enum' => array(
'view',
'edit'
),
);
return $query_params;
}

View File

@ -80,8 +80,8 @@ class REST_Items_Controller extends REST_Controller {
'permission_callback' => array($this, 'delete_item_permissions_check'),
'args' => array(
'permanently' => array(
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection', 'tainacan'),
'default' => 'false'
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection', 'tainacan'),
'default' => '0'
),
)
),
@ -757,9 +757,18 @@ class REST_Items_Controller extends REST_Controller {
$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',
'description' => 'The context in which the request is made.',
'enum' => array(
'view',
'edit'
),
);
$endpoint_args = array_merge(
$endpoint_args,
parent::get_fetch_only_param()
);
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
$map = $this->items_repository->get_map();
@ -785,16 +794,16 @@ class REST_Items_Controller extends REST_Controller {
* @return array|void
*/
public function get_wp_query_params() {
$query_params['context']['default'] = 'view';
array_merge($query_params, parent::get_wp_query_params());
$query_params['title'] = array(
'description' => __('Limits the result set to items with a specific title'),
'type' => 'string',
);
$query_params = array_merge($query_params, parent::get_meta_queries_params());
$query_params = array_merge(
$query_params,
parent::get_wp_query_params(),
parent::get_meta_queries_params()
);
return $query_params;
}

View File

@ -50,7 +50,6 @@ class REST_Metadata_Controller extends REST_Controller {
'permission_callback' => array($this, 'update_item_permissions_check'),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
),
// ENDPOINT X. THIS ENDPOINT DO THE SAME THING OF ENDPOINT Z. I hope in a brief future it function changes.
array(
'methods' => \WP_REST_Server::DELETABLE,
'callback' => array($this, 'delete_item'),

View File

@ -62,8 +62,8 @@ class REST_Taxonomies_Controller extends REST_Controller {
'permission_callback' => array($this, 'delete_item_permissions_check'),
'args' => array(
'permanently' => array(
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
'default' => 'false',
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
'default' => '0',
),
)
),

View File

@ -56,8 +56,9 @@ class REST_Terms_Controller extends REST_Controller {
'callback' => array($this, 'delete_item'),
'permission_callback' => array($this, 'delete_item_permissions_check'),
'args' => [
'info' => [
'description' => __('Delete term permanently.')
'permanently' => [
'description' => __('Delete term permanently.'),
'default' => '1'
]
]
),

View File

@ -94,6 +94,15 @@ class Log extends Entity {
function get_date() {
return $this->get_mapped_property( 'date' );
}
/**
* Return the log slug
*
* @return mixed|null
*/
function get_slug() {
return $this->get_mapped_property( 'slug' );
}
/**