WP_REST_Block_Types_Controller::get_item()publicWP 5.5.0

Retrieves a specific block type.

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

Хуков нет.

Возвращает

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

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

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

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

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

Код WP_REST_Block_Types_Controller::get_item() WP 6.5.2

public function get_item( $request ) {
	$block_name = sprintf( '%s/%s', $request['namespace'], $request['name'] );
	$block_type = $this->get_block( $block_name );
	if ( is_wp_error( $block_type ) ) {
		return $block_type;
	}
	$data = $this->prepare_item_for_response( $block_type, $request );

	return rest_ensure_response( $data );
}