wp-includes/class-wp-block-type-registry.php:15Core class used for interacting with block types.
$registered_block_typesWP_Block_Type[]private$name => $instance pairs.$instanceWP_Block_Type_Registry|nullprivate static#[AllowDynamicProperties]final class WP_Block_Type_Registry { /** * Registered block types, as `$name => $instance` pairs. * * @since 5.0.0 * @var WP_Block_Type[] */ private $registered_block_types = array(); /** * Container for the main instance of the class. * * @since 5.0.0 * @var WP_Block_Type_Registry|null */ private static $instance = null; /** * Registers a block type. * * @since 5.0.0 * * @see WP_Block_Type::__construct() * * @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. Accepts any public property * of `WP_Block_Type`. See WP_Block_Type::__construct() for information * on accepted arguments. Default empty array. * @return WP_Block_Type|false The registered block type on success, or false on failure. */ public function register( $name, $args = array() ) { $block_type = null; if ( $name instanceof WP_Block_Type ) { $block_type = $name; $name = $block_type->name; } if ( ! is_string( $name ) ) { _doing_it_wrong( __METHOD__, /* translators: %s: The received block type name type. */ sprintf( __( 'Block type names must be strings, received %s.' ), gettype( $name ) ), '5.0.0' ); return false; } if ( preg_match( '/[A-Z]+/', $name ) ) { _doing_it_wrong( __METHOD__, /* translators: %s: Block name. */ sprintf( __( 'Block type names must not contain uppercase characters. "%s" was given.' ), esc_html( $name ) ), '5.0.0' ); return false; } $name_matcher = '/^[a-z0-9-]+\/[a-z0-9-]+$/'; if ( ! preg_match( $name_matcher, $name ) ) { _doing_it_wrong( __METHOD__, /* translators: %s: Block name. */ sprintf( __( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type. "%s" was given.' ), esc_html( $name ) ), '5.0.0' ); return false; } if ( $this->is_registered( $name ) ) { _doing_it_wrong( __METHOD__, /* translators: %s: Block name. */ sprintf( __( 'Block type "%s" is already registered.' ), $name ), '5.0.0' ); return false; }Introduced in 5.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-block-type-registry.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.