/** * Get the query params for collections * * @return array */ public function get_collection_params() { $params = parent::get_collection_params(); if ('' !== $this->taxonomy) { $taxonomy = get_taxonomy($this->taxonomy); } else { $taxonomy = new stdClass(); $taxonomy->hierarchical = true; } $params['context']['default'] = 'view'; $params['exclude'] = array('description' => __('Ensure result set excludes specific ids.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['include'] = array('description' => __('Limit result set to specific ids.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); if (!$taxonomy->hierarchical) { $params['offset'] = array('description' => __('Offset the result set by a specific number of items.', 'woocommerce'), 'type' => 'integer', 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg'); } $params['order'] = array('description' => __('Order sort attribute ascending or descending.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_key', 'default' => 'asc', 'enum' => array('asc', 'desc'), 'validate_callback' => 'rest_validate_request_arg'); $params['orderby'] = array('description' => __('Sort collection by resource attribute.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_key', 'default' => 'name', 'enum' => array('id', 'include', 'name', 'slug', 'term_group', 'description', 'count'), 'validate_callback' => 'rest_validate_request_arg'); $params['hide_empty'] = array('description' => __('Whether to hide resources not assigned to any products.', 'woocommerce'), 'type' => 'boolean', 'default' => false, 'validate_callback' => 'rest_validate_request_arg'); if ($taxonomy->hierarchical) { $params['parent'] = array('description' => __('Limit result set to resources assigned to a specific parent.', 'woocommerce'), 'type' => 'integer', 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg'); } $params['product'] = array('description' => __('Limit result set to resources assigned to a specific product.', 'woocommerce'), 'type' => 'integer', 'default' => null, 'validate_callback' => 'rest_validate_request_arg'); $params['slug'] = array('description' => __('Limit result set to resources with a specific slug.', 'woocommerce'), 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg'); return $params; }
/** * Get the query params for collections. * * @return array */ public function get_collection_params() { $params = parent::get_collection_params(); $params['context']['default'] = 'view'; $params['exclude'] = array('description' => __('Ensure result set excludes specific ids.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['include'] = array('description' => __('Limit result set to specific ids.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['offset'] = array('description' => __('Offset the result set by a specific number of items.', 'woocommerce'), 'type' => 'integer', 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg'); $params['order'] = array('default' => 'asc', 'description' => __('Order sort attribute ascending or descending.', 'woocommerce'), 'enum' => array('asc', 'desc'), 'sanitize_callback' => 'sanitize_key', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg'); $params['orderby'] = array('default' => 'name', 'description' => __('Sort collection by object attribute.', 'woocommerce'), 'enum' => array('id', 'include', 'name', 'registered_date'), 'sanitize_callback' => 'sanitize_key', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg'); $params['email'] = array('description' => __('Limit result set to resources with a specific email.', 'woocommerce'), 'type' => 'string', 'format' => 'email', 'validate_callback' => 'rest_validate_request_arg'); $params['role'] = array('description' => __('Limit result set to resources with a specific role.', 'woocommerce'), 'type' => 'string', 'default' => 'customer', 'enum' => array_merge(array('all'), $this->get_role_names()), 'validate_callback' => 'rest_validate_request_arg'); return $params; }
/** * Get the query params for collections. * * @return array */ public function get_collection_params() { $params = parent::get_collection_params(); $params['context']['default'] = 'view'; $params['exclude'] = array('description' => __('Ensure result set excludes specific IDs.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['include'] = array('description' => __('Limit result set to specific IDs.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['offset'] = array('description' => __('Offset the result set by a specific number of items.', 'woocommerce'), 'type' => 'integer', 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg'); $params['order'] = array('default' => 'asc', 'description' => __('Order sort attribute ascending or descending.', 'woocommerce'), 'enum' => array('asc', 'desc'), 'sanitize_callback' => 'sanitize_key', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg'); $params['orderby'] = array('default' => 'order', 'description' => __('Sort collection by object attribute.', 'woocommerce'), 'enum' => array('id', 'order'), 'sanitize_callback' => 'sanitize_key', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg'); $params['class'] = array('description' => __('Sort by tax class.', 'woocommerce'), 'enum' => array_merge(array('standard'), array_map('sanitize_title', WC_Tax::get_tax_classes())), 'sanitize_callback' => 'sanitize_title', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg'); return $params; }
/** * Get the query params for collections of attachments. * * @return array */ public function get_collection_params() { $params = parent::get_collection_params(); $params['context']['default'] = 'view'; $params['after'] = array('description' => __('Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce'), 'type' => 'string', 'format' => 'date-time', 'validate_callback' => 'rest_validate_request_arg'); $params['before'] = array('description' => __('Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce'), 'type' => 'string', 'format' => 'date-time', 'validate_callback' => 'rest_validate_request_arg'); $params['exclude'] = array('description' => __('Ensure result set excludes specific IDs.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['include'] = array('description' => __('Limit result set to specific ids.', 'woocommerce'), 'type' => 'array', 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list'); $params['offset'] = array('description' => __('Offset the result set by a specific number of items.', 'woocommerce'), 'type' => 'integer', 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg'); $params['order'] = array('description' => __('Order sort attribute ascending or descending.', 'woocommerce'), 'type' => 'string', 'default' => 'desc', 'enum' => array('asc', 'desc'), 'validate_callback' => 'rest_validate_request_arg'); $params['orderby'] = array('description' => __('Sort collection by object attribute.', 'woocommerce'), 'type' => 'string', 'default' => 'date', 'enum' => array('date', 'id', 'include', 'title', 'slug'), 'validate_callback' => 'rest_validate_request_arg'); $post_type_obj = get_post_type_object($this->post_type); if (isset($post_type_obj->hierarchical) && $post_type_obj->hierarchical) { $params['parent'] = array('description' => __('Limit result set to those of particular parent IDs.', 'woocommerce'), 'type' => 'array', 'sanitize_callback' => 'wp_parse_id_list', 'default' => array()); $params['parent_exclude'] = array('description' => __('Limit result set to all items except those of a particular parent ID.', 'woocommerce'), 'type' => 'array', 'sanitize_callback' => 'wp_parse_id_list', 'default' => array()); } $params['filter'] = array('description' => __('Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce')); return $params; }