Update template to use new function register_block_type_from_metadata (#42711)
This commit is contained in:
parent
550cecf866
commit
35a68e212c
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: update
|
||||||
|
|
||||||
|
Update template to use new function register_block_type_from_metadata
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
|
use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
|
||||||
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface;
|
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.
|
* 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() {
|
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
|
||||||
if ( isset( $_GET['page'] ) && $_GET['page'] === 'wc-admin' ) {
|
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' );
|
add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' );
|
||||||
|
|
Loading…
Reference in New Issue