Update template to use new function register_block_type_from_metadata (#42711)

This commit is contained in:
Nathan Silveira 2023-12-13 10:38:33 -03:00 committed by GitHub
parent 550cecf866
commit 35a68e212c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Update template to use new function register_block_type_from_metadata

View File

@ -33,6 +33,8 @@
use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface;
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\BlockRegistry;
/**
* Registers the block using the metadata loaded from the `block.json` file.
@ -43,7 +45,7 @@ use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\Pr
*/
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
if ( isset( $_GET['page'] ) && $_GET['page'] === 'wc-admin' ) {
register_block_type( __DIR__ . '/build' );
BlockRegistry::get_instance()->register_block_type_from_metadata( __DIR__ . '/build' );
}
}
add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' );