WC_REST_Posts_Controller::get_collection_params()publicWC 1.0

Get the query params for collections of attachments.

Метод класса: WC_REST_Posts_Controller{}

Хуков нет.

Возвращает

Массив.

Использование

$WC_REST_Posts_Controller = new WC_REST_Posts_Controller();
$WC_REST_Posts_Controller->get_collection_params();

Код WC_REST_Posts_Controller::get_collection_params() WC 9.3.3

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',
		'items'             => array(
			'type'          => 'integer',
		),
		'default'           => array(),
		'sanitize_callback' => 'wp_parse_id_list',
	);
	$params['include'] = array(
		'description'       => __( 'Limit result set to specific ids.', 'woocommerce' ),
		'type'              => 'array',
		'items'             => array(
			'type'          => 'integer',
		),
		'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',
			'modified',
		),
		'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',
			'items'             => array(
				'type'          => 'integer',
			),
			'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',
			'items'             => array(
				'type'          => 'integer',
			),
			'sanitize_callback' => 'wp_parse_id_list',
			'default'           => array(),
		);
	}

	if ( 'wc/v1' === $this->namespace ) {
		$params['filter'] = array(
			'type'        => 'object',
			'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ),
		);
	}

	return $params;
}