Created
July 20, 2023 10:40
-
-
Save proweb/c7419ea89e08ab595da8114485dcfdd0 to your computer and use it in GitHub Desktop.
Revisions
-
proweb created this gist
Jul 20, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?php /** * Automatically registers block types by scanning the build/blocks folder. * * This function searches for JSON files within each subfolder and registers * them as block types. It is triggered on WordPress 'init' action. */ function auto_register_block_types() { if ( file_exists( __DIR__ . '/build/blocks/' ) ) { $block_json_files = glob( __DIR__ . '/build/blocks/*/block.json' ); foreach ( $block_json_files as $filename ) { $block_folder = dirname( $filename ); register_block_type( $block_folder ); } } } add_action( 'init', 'auto_register_block_types' );