WC_REST_Product_Reviews_Controller::get_collection_params()publicWC 1.0

Get the query params for collections.

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

Возвращает

Массив.

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

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

Код WC_REST_Product_Reviews_Controller::get_collection_params() WC 8.7.0

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',
	);
	$params['before']           = array(
		'description' => __( 'Limit response to reviews published before a given ISO8601 compliant date.', 'woocommerce' ),
		'type'        => 'string',
		'format'      => 'date-time',
	);
	$params['exclude']          = array(
		'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
		'type'        => 'array',
		'items'       => array(
			'type' => 'integer',
		),
		'default'     => array(),
	);
	$params['include']          = array(
		'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
		'type'        => 'array',
		'items'       => array(
			'type' => 'integer',
		),
		'default'     => array(),
	);
	$params['offset']           = array(
		'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
		'type'        => 'integer',
	);
	$params['order']            = array(
		'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
		'type'        => 'string',
		'default'     => 'desc',
		'enum'        => array(
			'asc',
			'desc',
		),
	);
	$params['orderby']          = array(
		'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
		'type'        => 'string',
		'default'     => 'date_gmt',
		'enum'        => array(
			'date',
			'date_gmt',
			'id',
			'include',
			'product',
		),
	);
	$params['reviewer']         = array(
		'description' => __( 'Limit result set to reviews assigned to specific user IDs.', 'woocommerce' ),
		'type'        => 'array',
		'items'       => array(
			'type' => 'integer',
		),
	);
	$params['reviewer_exclude'] = array(
		'description' => __( 'Ensure result set excludes reviews assigned to specific user IDs.', 'woocommerce' ),
		'type'        => 'array',
		'items'       => array(
			'type' => 'integer',
		),
	);
	$params['reviewer_email']   = array(
		'default'     => null,
		'description' => __( 'Limit result set to that from a specific author email.', 'woocommerce' ),
		'format'      => 'email',
		'type'        => 'string',
	);
	$params['product']          = array(
		'default'     => array(),
		'description' => __( 'Limit result set to reviews assigned to specific product IDs.', 'woocommerce' ),
		'type'        => 'array',
		'items'       => array(
			'type' => 'integer',
		),
	);
	$params['status']           = array(
		'default'           => 'approved',
		'description'       => __( 'Limit result set to reviews assigned a specific status.', 'woocommerce' ),
		'sanitize_callback' => 'sanitize_key',
		'type'              => 'string',
		'enum'              => array(
			'all',
			'hold',
			'approved',
			'spam',
			'trash',
		),
	);

	/**
	 * Filter collection parameters for the reviews controller.
	 *
	 * This filter registers the collection parameter, but does not map the
	 * collection parameter to an internal WP_Comment_Query parameter. Use the
	 * `wc_rest_review_query` filter to set WP_Comment_Query parameters.
	 *
	 * @since 3.5.0
	 * @param array $params JSON Schema-formatted collection parameters.
	 */
	return apply_filters( 'woocommerce_rest_product_review_collection_params', $params );
}