get_type(); if ( empty( $block_type ) ) { return new WP_Error( 'block_type_undefined', 'The type must be set' ); } if ( isset( self::$_blocks[ $block_type ] ) ) { return new WP_Error( 'block_already_registered', 'Block type already registered: ' . $block_type ); } // Register block. self::$_blocks[ $block_type ] = $block; // Initialize block. call_user_func( array( $block, 'init' ) ); return true; } /** * Get instance of block. * * @since 2.4.10 * * @param string $block_type Block type. * * @return GF_Block|bool */ public static function get( $block_type ) { return isset( self::$_blocks[ $block_type ] ) ? self::$_blocks[ $block_type ] : false; } /** * Returns an array of registered block types. * * @since 2.4.18 * * @return array */ public static function get_all_types() { return array_keys( self::$_blocks ); } } new GF_Blocks();