diff --git a/web/app/plugins/mitlib-post-hero-images/mitlib-post-hero-images.php b/web/app/plugins/mitlib-post-hero-images/mitlib-post-hero-images.php index 37246227..9aebeb7f 100644 --- a/web/app/plugins/mitlib-post-hero-images/mitlib-post-hero-images.php +++ b/web/app/plugins/mitlib-post-hero-images/mitlib-post-hero-images.php @@ -23,22 +23,7 @@ // Register class methods with the WordPress hooks which will call them. add_action( 'init', array( 'Mitlib\PostTypes\HeroImage', 'define' ) ); +add_action( 'init', array( 'Mitlib\PostTypes\HeroImage', 'register_blocks' ) ); add_action( 'rest_api_init', array( 'Mitlib\PostTypes\HeroImage', 'api_enable' ) ); add_filter( 'acf/settings/load_json', array( 'Mitlib\PostTypes\HeroImage', 'load_point' ) ); add_filter( 'acf/settings/save_json', array( 'Mitlib\PostTypes\HeroImage', 'save_point' ) ); - -/** - * Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s) - * based on the registered block metadata. Behind the scenes, it registers also all assets so they can be enqueued - * through the block editor in the corresponding context. - * - * @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/ - * @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/ - */ -function register_blocks() { - wp_register_block_types_from_metadata_collection( - __DIR__ . '/build', - __DIR__ . '/build/blocks-manifest.php' - ); -} -add_action( 'init', 'Mitlib\PostTypes\register_blocks' ); diff --git a/web/app/plugins/mitlib-post-hero-images/src/class-heroimage.php b/web/app/plugins/mitlib-post-hero-images/src/class-heroimage.php index 02894ffc..5cf265b7 100644 --- a/web/app/plugins/mitlib-post-hero-images/src/class-heroimage.php +++ b/web/app/plugins/mitlib-post-hero-images/src/class-heroimage.php @@ -88,4 +88,19 @@ public static function define() { register_post_type( 'hero_images', $args ); } + + /** + * Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s) + * based on the registered block metadata. Behind the scenes, it registers also all assets so they can be enqueued + * through the block editor in the corresponding context. + * + * @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/ + * @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/ + */ + public static function register_blocks() { + wp_register_block_types_from_metadata_collection( + plugin_dir_path( __DIR__ ) . 'build', + plugin_dir_path( __DIR__ ) . 'build/blocks-manifest.php' + ); + } }