WP_REST_Block_Patterns_Controller::get_items()publicWP 6.0.0

Retrieves all block patterns.

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

Хуков нет.

Возвращает

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

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

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

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

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

Код WP_REST_Block_Patterns_Controller::get_items() WP 6.0.2

public function get_items( $request ) {
	if ( ! $this->remote_patterns_loaded ) {
		// Load block patterns from w.org.
		_load_remote_block_patterns(); // Patterns with the `core` keyword.
		_load_remote_featured_patterns(); // Patterns in the `featured` category.
		_register_remote_theme_patterns(); // Patterns requested by current theme.

		$this->remote_patterns_loaded = true;
	}

	$response = array();
	$patterns = WP_Block_Patterns_Registry::get_instance()->get_all_registered();
	foreach ( $patterns as $pattern ) {
		$prepared_pattern = $this->prepare_item_for_response( $pattern, $request );
		$response[]       = $this->prepare_response_for_collection( $prepared_pattern );
	}
	return rest_ensure_response( $response );
}