update to match the newer core API proposed
This commit is contained in:
parent
5d665bf0c3
commit
a3f4439db0
|
@ -254,9 +254,8 @@ abstract class AbstractBlock {
|
||||||
// Prefer to register with metadata if the path is set in the block's class.
|
// Prefer to register with metadata if the path is set in the block's class.
|
||||||
if ( ! empty( $metadata_path ) ) {
|
if ( ! empty( $metadata_path ) ) {
|
||||||
register_block_type_from_metadata(
|
register_block_type_from_metadata(
|
||||||
$metadata_path,
|
$this->namespace . '/' . $this->block_name,
|
||||||
$block_settings,
|
$block_settings
|
||||||
$this->namespace . '/' . $this->block_name
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,10 @@ abstract class AbstractInnerBlock extends AbstractBlock {
|
||||||
$block_settings['api_version'] = 2;
|
$block_settings['api_version'] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata_path = $this->asset_api->get_block_metadata_path( $this->block_name, 'inner-blocks/' );
|
|
||||||
// Prefer to register with metadata if the path is set in the block's class.
|
// Prefer to register with metadata if the path is set in the block's class.
|
||||||
register_block_type_from_metadata(
|
register_block_type_from_metadata(
|
||||||
$metadata_path,
|
$this->namespace . '/' . $this->block_name,
|
||||||
$block_settings,
|
$block_settings
|
||||||
$this->namespace . '/' . $this->block_name
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,17 +160,7 @@ final class BlockTypesController {
|
||||||
if ( function_exists( 'wp_register_block_metadata' ) && file_exists( $meta_file_path ) ) {
|
if ( function_exists( 'wp_register_block_metadata' ) && file_exists( $meta_file_path ) ) {
|
||||||
$block_metadata = require $meta_file_path;
|
$block_metadata = require $meta_file_path;
|
||||||
foreach ( $block_metadata as $full_block_name => $block_data ) {
|
foreach ( $block_metadata as $full_block_name => $block_data ) {
|
||||||
$name_parts = explode( '/', $full_block_name, 2 );
|
wp_register_block_metadata( $full_block_name, $block_data );
|
||||||
|
|
||||||
if ( count( $name_parts ) > 1 ) {
|
|
||||||
$namespace = $name_parts[0];
|
|
||||||
$block_name = $name_parts[1];
|
|
||||||
} else {
|
|
||||||
$namespace = 'woocommerce'; // Fallback, don't expect to hit this
|
|
||||||
$block_name = $full_block_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_register_block_metadata( $namespace, $block_name, $block_data );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue