Update block registration methods in documentation for WordPress 6.8+#76324
Update block registration methods in documentation for WordPress 6.8+#76324juanmaguitar merged 1 commit intotrunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in c906fa6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22860111015
|
What?
Updates the block registration documentation to cover the newer, more efficient registration APIs introduced in WordPress 6.7 and 6.8.
Why?
The current docs only describe
register_block_type()for server-side block registration. WordPress 6.7 introducedwp_register_block_metadata_collection()andWordPress 6.8 introduced
wp_register_block_types_from_metadata_collection()— which is now the recommended approach and what@wordpress/create-blockscaffolds bydefault. The docs should reflect this.
How?
registration-of-a-block.md:wp_register_block_types_from_metadata_collection()(recommended, WP 6.8+)wp_register_block_metadata_collection()+ individualregister_block_type()(WP 6.7+)register_block_type()(single blocks or older WP versions)file-structure-of-a-block.md:<plugin-file>.phpsection to mentionwp_register_block_types_from_metadata_collection()as the recommended approach, with a cross-link to the fullregistration docs