fixes `_doing_it_wrong` notices if the type keyword is missing or contains invalid values
This commit is contained in:
parent
112f7a5f34
commit
530a86b7f1
|
@ -274,7 +274,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
public function get_fetch_only_param(){
|
||||
return [
|
||||
'fetch_only' => array(
|
||||
'type' => 'string/array',
|
||||
'type' => ['string','array'],
|
||||
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.', 'tainacan' ),
|
||||
//TODO: explicar o fetch only meta.. cabe aqui?
|
||||
)
|
||||
|
@ -338,15 +338,18 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
|
||||
$query_params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.', 'tainacan' ),
|
||||
'type' => 'string/array',
|
||||
'type' => ['string','array'],
|
||||
'default' => 'desc',
|
||||
'enum' => array( 'asc', 'desc', 'ASC', 'DESC' ),
|
||||
);
|
||||
|
||||
$query_params['orderby'] = array(
|
||||
'description' => __( "Sort objects by object attribute.", 'tainacan' ),
|
||||
'type' => 'string/array',
|
||||
'type' => ['string', 'array'],
|
||||
'default' => 'date',
|
||||
// 'items' => [
|
||||
// 'type' => 'string'
|
||||
// ],
|
||||
'enum' => array(
|
||||
'author',
|
||||
'date',
|
||||
|
@ -366,7 +369,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
|
||||
$query_params['perpage'] = array(
|
||||
'description' => __( "Maximum number of objects to be returned in result set.", 'tainacan' ),
|
||||
'type' => 'numeric',
|
||||
'type' => 'number',
|
||||
'default' => 10,
|
||||
);
|
||||
|
||||
|
@ -394,11 +397,11 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
protected function get_meta_queries_params(){
|
||||
return array(
|
||||
'metakey' => array(
|
||||
'type' => 'integer/string',
|
||||
'type' => ['integer', 'string'],
|
||||
'description' => __('Custom metadata key.'),
|
||||
),
|
||||
'metavalue' => array(
|
||||
'type' => 'string/array',
|
||||
'type' => ['string', 'array'],
|
||||
'description' => __('Custom metadata value'),
|
||||
),
|
||||
'metavaluenum' => array(
|
||||
|
@ -430,7 +433,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
),
|
||||
'metaquery' => array(
|
||||
'description' => __('Limits result set to items that have specific custom metadata'),
|
||||
'type' => 'array/object',
|
||||
'type' => ['array', 'object'],
|
||||
'items' => array(
|
||||
'keys' => array(
|
||||
'key' => array(
|
||||
|
@ -438,7 +441,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
'description' => __('Custom metadata key.'),
|
||||
),
|
||||
'value' => array(
|
||||
'type' => 'string/array',
|
||||
'type' => ['string', 'array'],
|
||||
'description' => __('Custom metadata value. It can be an array only when compare is IN, NOT IN, BETWEEN, or NOT BETWEEN. You dont have to specify a value when using the EXISTS or NOT EXISTS comparisons in WordPress 3.9 and up.
|
||||
(Note: Due to bug #23268, value is required for NOT EXISTS comparisons to work correctly prior to 3.9. You must supply some string for the value parameter. An empty string or NULL will NOT work. However, any other string will do the trick and will NOT show up in your SQL when using NOT EXISTS. Need inspiration? How about \'bug #23268\'.'),
|
||||
),
|
||||
|
@ -478,7 +481,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
),
|
||||
'datequery' => array(
|
||||
'description' => __('Limits the result set to items that were created or modified in some specific date'),
|
||||
'type' => 'array/object',
|
||||
'type' => ['array', 'object'],
|
||||
'items' => array(
|
||||
'keys' => array(
|
||||
'year' => array(
|
||||
|
@ -536,11 +539,11 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
'description' => __('For after/before, whether exact value should be matched or not.'),
|
||||
),
|
||||
'before' => array(
|
||||
'type' => 'string/array',
|
||||
'type' => ['string', 'array'],
|
||||
'description' => __('Date to retrieve posts before. Accepts strtotime()-compatible string, or array of year, month, day '),
|
||||
),
|
||||
'after' => array(
|
||||
'type' => 'string/array',
|
||||
'type' => ['string', 'array'],
|
||||
'description' => __('Date to retrieve posts after. Accepts strtotime()-compatible string, or array of year, month, day '),
|
||||
),
|
||||
'column' => array(
|
||||
|
@ -553,7 +556,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
),
|
||||
'taxquery' => array(
|
||||
'description' => __('Show items associated with certain taxonomy.'),
|
||||
'type' => 'array/object',
|
||||
'type' => ['array', 'object'],
|
||||
'items' => array(
|
||||
'keys' => array(
|
||||
'taxonomy' => array(
|
||||
|
@ -572,7 +575,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
)
|
||||
),
|
||||
'terms' => array(
|
||||
'type' => 'int/string/array',
|
||||
'type' => ['integer', 'string', 'array'],
|
||||
'description' => __('Taxonomy term(s).'),
|
||||
),
|
||||
'operator' => array(
|
||||
|
|
|
@ -41,7 +41,7 @@ class REST_Background_Processes_Controller extends REST_Controller {
|
|||
'description' => __( 'The ID of the owner of the background processes. Defaults to current user', 'tainacan' ),
|
||||
],
|
||||
'all_users' => [
|
||||
'type' => 'bool',
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to return processes from all users (if current user is admin).', 'tainacan' ),
|
||||
'default' => false,
|
||||
],
|
||||
|
@ -66,7 +66,7 @@ class REST_Background_Processes_Controller extends REST_Controller {
|
|||
'default' => 1
|
||||
],
|
||||
'recent' => [
|
||||
'type' => 'bool',
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Returns only processes created or updated recently', 'tainacan' ),
|
||||
'default' => false
|
||||
],
|
||||
|
|
|
@ -57,7 +57,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'string/integer',
|
||||
'type' => ['string', 'integer'],
|
||||
'description' => __( 'The value to be added', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -118,7 +118,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'string/integer/array',
|
||||
'type' => ['string', 'integer', 'array'],
|
||||
'description' => __( 'The value to be set', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -137,7 +137,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'metadatum_id_from' => [
|
||||
'type' => 'string/integer',
|
||||
'type' => ['string', 'integer'],
|
||||
'description' => __( 'The metadatum ID to be copied', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -156,7 +156,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'string/integer',
|
||||
'type' => ['string', 'integer'],
|
||||
'description' => __( 'The value to be added', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -175,11 +175,11 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'old_value' => [
|
||||
'type' => 'string/integer',
|
||||
'type' => ['string', 'integer'],
|
||||
'description' => __( 'The value to search for', 'tainacan' ),
|
||||
],
|
||||
'new_value' => [
|
||||
'type' => 'string/integer',
|
||||
'type' => ['string', 'integer'],
|
||||
'description' => __( 'The value to be set', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -433,7 +433,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
];
|
||||
|
||||
$query_params['use_query'] = [
|
||||
'type' => 'bool',
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Whether to use the current query to select posts', 'tainacan' ),
|
||||
];
|
||||
|
||||
|
|
|
@ -70,11 +70,11 @@ class REST_Exporters_Controller extends REST_Controller {
|
|||
'description' => __( 'The e-mail to be used by the export to send a message when the process ends', 'tainacan' ),
|
||||
],
|
||||
'collection' => [
|
||||
'type' => 'array/object',
|
||||
'type' => ['array', 'object'],
|
||||
'description' => __( 'The array describing the collection as expected by the exporter', 'tainacan' ),
|
||||
],
|
||||
'options' => [
|
||||
'type' => 'array/object',
|
||||
'type' => ['array', 'object'],
|
||||
'description' => __( 'The exporter options', 'tainacan' ),
|
||||
]
|
||||
],
|
||||
|
|
|
@ -56,11 +56,11 @@ class REST_Importers_Controller extends REST_Controller {
|
|||
'description' => __( 'The URL to be used by the importer', 'tainacan' ),
|
||||
],
|
||||
'collection' => [
|
||||
'type' => 'array/object',
|
||||
'type' => ['array','object'],
|
||||
'description' => __( 'The array describing the destination collectino as expected by the importer', 'tainacan' ),
|
||||
],
|
||||
'options' => [
|
||||
'type' => 'array/object',
|
||||
'type' => ['array', 'object'],
|
||||
'description' => __( 'The importer options', 'tainacan' ),
|
||||
]
|
||||
],
|
||||
|
|
|
@ -282,15 +282,15 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
);
|
||||
} elseif ($method === \WP_REST_Server::EDITABLE) {
|
||||
$endpoint_args['values'] = [
|
||||
'type' => 'array/string/object/integer',
|
||||
'type' => ['array', 'string', 'object', 'integer'],
|
||||
'items' => [
|
||||
'type' => 'array/string/object/integer'
|
||||
'type' => ['array', 'string', 'object', 'integer']
|
||||
],
|
||||
'description' => __('The value(s) of item metadata')
|
||||
];
|
||||
$endpoint_args['parent_meta_id'] = [
|
||||
'type' => 'array/string/object/integer',
|
||||
'items' => ['type' => 'array/string/object/integer'],
|
||||
'type' => ['array', 'string', 'object', 'integer'],
|
||||
'items' => ['type' => ['array', 'string', 'object', 'integer'] ],
|
||||
'description' => __('The parent meta ID for the item metadata children group')
|
||||
];
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class REST_Metadata_Types_Controller extends REST_Controller {
|
|||
'type' => 'string'
|
||||
],
|
||||
'primitive_type' => [
|
||||
'type' => 'array/string',
|
||||
'type' => ['array','string'],
|
||||
'items' => [
|
||||
'type' => 'string'
|
||||
]
|
||||
|
|
|
@ -65,7 +65,7 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
|||
)
|
||||
),
|
||||
'fetch_only' => array(
|
||||
'type' => 'string/array',
|
||||
'type' => ['string', 'array'],
|
||||
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.', 'tainacan' ),
|
||||
)
|
||||
)
|
||||
|
|
|
@ -108,8 +108,8 @@ class Collections extends Repository {
|
|||
'default_displayed_metadata' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Default Displayed Metadata', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'type' => ['array', 'object', 'string'],
|
||||
'items' => [ 'type' => ['array','string', 'integer', 'object'] ],
|
||||
'default' => [],
|
||||
'description' => __( 'List of collection properties that will be displayed in the table view', 'tainacan' ),
|
||||
//'validation' => v::stringType(),
|
||||
|
@ -134,16 +134,16 @@ class Collections extends Repository {
|
|||
'metadata_order' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Metadata order', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'type' => ['array', 'object', 'string'],
|
||||
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
|
||||
'description' => __( 'The order of the metadata in the collection', 'tainacan' ),
|
||||
//'validation' => v::stringType(),
|
||||
],
|
||||
'filters_order' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Filters order', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'type' => ['array', 'object', 'string'],
|
||||
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
|
||||
'description' => __( 'The order of the filters in the collection', 'tainacan' ),
|
||||
//'validation' => v::stringType(),
|
||||
],
|
||||
|
@ -159,7 +159,7 @@ class Collections extends Repository {
|
|||
'cover_page_id' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Cover Page ID', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'type' => ['integer', 'string'],
|
||||
'description' => __( 'If enabled, this custom page will be used as cover for this collection, instead of default items list.', 'tainacan' ),
|
||||
'on_error' => __( 'Invalid page', 'tainacan' ),
|
||||
//'validation' => v::numeric(),
|
||||
|
|
|
@ -56,8 +56,8 @@ class Filters extends Repository {
|
|||
'filter_type_options' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Filter type options', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'type' => ['array', 'object', 'string'],
|
||||
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
|
||||
'description' => __( 'The filter type options', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
|
@ -71,14 +71,14 @@ class Filters extends Repository {
|
|||
'collection_id' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Collection', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'type' => ['integer', 'string'],
|
||||
'description' => __( 'The collection ID', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'color' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Color', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'type' => ['integer', 'string'],
|
||||
'description' => __( 'Filter color', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
|
@ -92,7 +92,7 @@ class Filters extends Repository {
|
|||
'max_options' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Max of options', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'type' => ['integer', 'string'],
|
||||
'description' => __( 'The max number of options to be showed in filter sidebar.', 'tainacan' ),
|
||||
'validation' => '',
|
||||
'default' => 4
|
||||
|
|
|
@ -131,7 +131,7 @@ class Metadata extends Repository {
|
|||
'cardinality' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Cardinality', 'tainacan' ),
|
||||
'type' => 'string/number',
|
||||
'type' => ['string', 'number'],
|
||||
'description' => __( 'Number of multiples possible metadata', 'tainacan' ),
|
||||
'on_error' => __( 'This number of multiples metadata is not allowed', 'tainacan' ),
|
||||
'validation' => v::numeric()->positive(),
|
||||
|
@ -154,22 +154,22 @@ class Metadata extends Repository {
|
|||
'metadata_type_options' => [ // not showed in form
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Metadata type options', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'type' => ['array', 'object', 'string'],
|
||||
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
|
||||
'description' => __( 'Specific options for metadata type', 'tainacan' ),
|
||||
// 'validation' => ''
|
||||
],
|
||||
'collection_id' => [ // not showed in form
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Collection', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'type' => ['integer', 'string'],
|
||||
'description' => __( 'The collection ID', 'tainacan' ),
|
||||
//'validation' => ''
|
||||
],
|
||||
'accept_suggestion' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Metadata Value Accepts Suggestions', 'tainacan' ),
|
||||
'type' => 'bool',
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Allow community to suggest different values for the metadata', 'tainacan' ),
|
||||
'default' => false,
|
||||
'validation' => v::boolType()
|
||||
|
@ -177,8 +177,8 @@ class Metadata extends Repository {
|
|||
'exposer_mapping' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Relationship metadata mapping', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'type' => ['array', 'object', 'string'],
|
||||
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
|
||||
'description' => __( 'The metadata mapping options. Metadata can be configured to match another type of data distribution.', 'tainacan' ),
|
||||
'on_error' => __( 'Invalid Metadata Mapping', 'tainacan' ),
|
||||
//'validation' => v::arrayType(),
|
||||
|
@ -187,7 +187,7 @@ class Metadata extends Repository {
|
|||
'display' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Display', 'tainacan' ),
|
||||
'type' => __( 'string' ),
|
||||
'type' => 'string',
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no', 'never' ] ),
|
||||
'description' => __( 'Display by default on listing or do not display or never display.', 'tainacan' ),
|
||||
'default' => 'no'
|
||||
|
@ -195,7 +195,7 @@ class Metadata extends Repository {
|
|||
'semantic_uri' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'The semantic metadatum description URI' ),
|
||||
'type' => __( 'url' ),
|
||||
'type' => 'string',
|
||||
'validation' => v::optional( v::url() ),
|
||||
'description' => __( 'The semantic metadatum description URI like: ', 'tainacan' ) . 'https://schema.org/URL',
|
||||
'default' => ''
|
||||
|
|
|
@ -68,7 +68,7 @@ class Taxonomies extends Repository {
|
|||
'enabled_post_types' => [
|
||||
'map' => 'meta_multi',
|
||||
'title' => __( 'Enabled for post types', 'tainacan' ),
|
||||
'type' => 'array/string',
|
||||
'type' => ['array', 'string'],
|
||||
'description' => __( 'Also enable this taxonomy for other WordPress post types', 'tainacan' ),
|
||||
'on_error' => __( 'Error enabling this taxonomy for post types', 'tainacan' ),
|
||||
'validation' => '',
|
||||
|
|
|
@ -91,7 +91,7 @@ class Terms extends Repository {
|
|||
'hide_empty' => [
|
||||
'map' => 'hide_empty',
|
||||
'title' => __( 'Hide empty', 'tainacan' ),
|
||||
'type' => 'bool',
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Hide empty terms', 'tainacan' )
|
||||
]
|
||||
] );
|
||||
|
|
Loading…
Reference in New Issue