Unlock Hidden Gems: Insider Secrets in WordPress 6.8 for Developers
Because all of the block data is stored as PHP in blocks-manifest.php
, you can register all of your plugin’s block types without reading individual JSON files. Overall, it’s just a more efficient way to register block types—and yes, you can use it for registering single block types, too!
In WordPress 6.8, you can register all of your block types with this call:
wp_register_block_types_from_metadata_collection(
__DIR__ . '/build',
__DIR__ . '/build/blocks-manifest.php'
);
Read the developer note on the Make WordPress Core blog for more information or to find out how to use this in a backward-compatible way when supporting older versions of WordPress.