WP_REST_Block_Types_Controller::get_block
Get the block, if the name is valid.
Method of the class: WP_REST_Block_Types_Controller{}
No Hooks.
Returns
WP_Block_Type|WP_Error. Block type object if name is valid, WP_Error otherwise.
Usage
// protected - for code of main (parent) or child class $result = $this->get_block( $name );
- $name(string) (required)
- Block name.
Changelog
| Since 5.5.0 | Introduced. |
WP_REST_Block_Types_Controller::get_block() WP REST Block Types Controller::get block code WP 7.0
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;
}