WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_REST_CRUD_Controller::prepare_objects_query() WC 3.0.0

Prepare objects query.

Это метод класса: WC_REST_CRUD_Controller

Хуки из метода
Возвращает

Массив.

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

$WC_REST_CRUD_Controller = new WC_REST_CRUD_Controller();
$var = $WC_REST_CRUD_Controller->prepare_objects_query( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Список изменений

С версии 3.0.0 Введена.

Код WC REST CRUD Controller::prepare objects query: woocommerce/packages/woocommerce-rest-api/src/Controllers/Version3/class-wc-rest-crud-controller.php WC 4.3.0

<?php
protected function prepare_objects_query( $request ) {
	$args                        = array();
	$args['offset']              = $request['offset'];
	$args['order']               = $request['order'];
	$args['orderby']             = $request['orderby'];
	$args['paged']               = $request['page'];
	$args['post__in']            = $request['include'];
	$args['post__not_in']        = $request['exclude'];
	$args['posts_per_page']      = $request['per_page'];
	$args['name']                = $request['slug'];
	$args['post_parent__in']     = $request['parent'];
	$args['post_parent__not_in'] = $request['parent_exclude'];
	$args['s']                   = $request['search'];

	if ( 'date' === $args['orderby'] ) {
		$args['orderby'] = 'date ID';
	}

	$args['date_query'] = array();
	// Set before into date query. Date query must be specified as an array of an array.
	if ( isset( $request['before'] ) ) {
		$args['date_query'][0]['before'] = $request['before'];
	}

	// Set after into date query. Date query must be specified as an array of an array.
	if ( isset( $request['after'] ) ) {
		$args['date_query'][0]['after'] = $request['after'];
	}

	// Force the post_type argument, since it's not a user input variable.
	$args['post_type'] = $this->post_type;

	/**
	 * Filter the query arguments for a request.
	 *
	 * Enables adding extra arguments or setting defaults for a post
	 * collection request.
	 *
	 * @param array           $args    Key value array of query var to query value.
	 * @param WP_REST_Request $request The request used.
	 */
	$args = apply_filters( "woocommerce_rest_{$this->post_type}_object_query", $args, $request );

	return $this->prepare_items_query( $args, $request );
}