WC_REST_Data_Controller::get_items()publicWC 3.5.0

Return the list of data resources.

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

Хуков нет.

Возвращает

WP_Error|WP_REST_Response.

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

$WC_REST_Data_Controller = new WC_REST_Data_Controller();
$WC_REST_Data_Controller->get_items( $request );
$request(WP_REST_Request) (обязательный)
Request data.

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

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

Код WC_REST_Data_Controller::get_items() WC 9.3.3

public function get_items( $request ) {
	$data      = array();
	$resources = array(
		array(
			'slug'        => 'continents',
			'description' => __( 'List of supported continents, countries, and states.', 'woocommerce' ),
		),
		array(
			'slug'        => 'countries',
			'description' => __( 'List of supported states in a given country.', 'woocommerce' ),
		),
		array(
			'slug'        => 'currencies',
			'description' => __( 'List of supported currencies.', 'woocommerce' ),
		),
	);

	foreach ( $resources as $resource ) {
		$item   = $this->prepare_item_for_response( (object) $resource, $request );
		$data[] = $this->prepare_response_for_collection( $item );
	}

	return rest_ensure_response( $data );
}