WP_REST_Block_Types_Controller::get_block( string $name ): WP_Block_Type|WP_Error

In this article

Get the block, if the name is valid.

Parameters

$namestringrequired
Block name.

Return

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

Source

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;
}

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

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