WP_REST_Block_Types_Controller::get_block( string $name )

Get the block, if the name is valid.


Parameters Parameters

$name

(string) (Required) Block name.


Top ↑

Return Return

(WP_Block_Type|WP_Error) Block type object if name is valid, WP_Error otherwise.


Top ↑

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php

	protected function get_block( $name ) {
		$block_type = $this->block_registry->get_registered( $name );
		if ( empty( $block_type ) ) {
			return new WP_Error( 'rest_block_type_invalid', __( 'Invalid block type.' ), array( 'status' => 404 ) );
		}

		return $block_type;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.