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

Get the block, if the name is valid.


Parameters

$name string Required
Block name.

Top ↑

Return

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


Top ↑

Source

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

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
Version Description
5.5.0 Introduced.

Top ↑

User Contributed Notes

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