WP_REST_Block_Pattern_Categories_Controller::get_items()publicWP 6.0.0

Retrieves all block pattern categories.

{} Это метод класса: WP_REST_Block_Pattern_Categories_Controller{}

Хуков нет.

Возвращает

WP_Error|WP_REST_Response. Response object on success, or WP_Error object on failure.

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

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

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

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

Код WP_REST_Block_Pattern_Categories_Controller::get_items() WP 6.0.2

public function get_items( $request ) {
	$response   = array();
	$categories = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered();
	foreach ( $categories as $category ) {
		$prepared_category = $this->prepare_item_for_response( $category, $request );
		$response[]        = $this->prepare_response_for_collection( $prepared_category );
	}

	return rest_ensure_response( $response );
}