diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index b04696d591..2ec3a07e3e 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -7,6 +7,39 @@ * @since 5.0.0 */ +/** + * Registers a block type. + * + * @since 5.0.0 + * + * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a + * complete WP_Block_Type instance. In case a WP_Block_Type + * is provided, the $args parameter will be ignored. + * @param array $args { + * Optional. Array of block type arguments. Any arguments may be defined, however the + * ones described below are supported by default. Default empty array. + * + * @type callable $render_callback Callback used to render blocks of this block type. + * } + * @return WP_Block_Type|false The registered block type on success, or false on failure. + */ +function register_block_type( $name, $args = array() ) { + return WP_Block_Type_Registry::get_instance()->register( $name, $args ); +} + +/** + * Unregisters a block type. + * + * @since 5.0.0 + * + * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a + * complete WP_Block_Type instance. + * @return WP_Block_Type|false The unregistered block type on success, or false on failure. + */ +function unregister_block_type( $name ) { + return WP_Block_Type_Registry::get_instance()->unregister( $name ); +} + /** * Determine whether a post or content string has blocks. * @@ -59,3 +92,23 @@ function has_block( $block_type, $post = null ) { return false !== strpos( $post, '