W3cubDocs

/WordPress

WP_REST_Block_Types_Controller::get_block( string $name )

Get the block, if the name is valid.

Parameters

$name

(string) (Required) Block name.

Return

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

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

Changelog

Version Description
5.5.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_block_types_controller/get_block