Skip to content

Conversation

@jonathanbossenger
Copy link
Contributor

What?

Closes #74645

Why?

Simplifies the code generated to register blocks in the main plugin file to default to using the new wp_register_block_types_from_metadata_collection function.

Leaves the links to the update posts in the comments, so that developers building blocks for older WordPress versions can make the necessary changes manually.

How?

  • Updates the requiresAtLeast version to 6.8
  • Updates the main plugin code to use only the wp_register_block_types_from_metadata_collection function

Testing Instructions

  1. Generate a new block using create-block
  2. Confirm that the new code registers the block correctly in a WordPress 6.8+ install
  3. Confirm that the plugin does not activate in a WordPress 6.7 or lower install

Simplify's the code generated to register blocks in the main plugin file
to default to using the new wp_register_block_types_from_metadata_collection function.

Leaves the links to the update posts in the comments, so that developers building blocks
for older WordPress versions can make the nessecary changes manually.
@github-actions
Copy link

github-actions bot commented Jan 15, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jonathanbossenger <psykro@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jonathanbossenger jonathanbossenger added [Type] Enhancement A suggestion for improvement. [Tool] Create Block /packages/create-block labels Jan 15, 2026
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good given that now we are requring at least WordPress 6.8 and we know wp_register_block_types_from_metadata_collection is available there.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good given that now we are requring at least WordPress 6.8 and we know wp_register_block_types_from_metadata_collection is available there.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanbossenger Can you update the document as well?

- `requiresAtLeast` (default: `'6.7'`) – the lowest WordPress version that the plugin will work on.

We may need to update testedUpTo as well.

- `testedUpTo` (default: `'6.7'`) – the highest WordPress version that the plugin has been tested against.

@SirLouen SirLouen added the Needs Testing Needs further testing to be confirmed. label Jan 15, 2026
@juanmaguitar
Copy link
Contributor

juanmaguitar commented Jan 15, 2026

Reproduction Report

This report validates that the PR works as expected

Environment

  • WordPress: 6.9
  • Node: v22.15.1
  • NPM: 10.9.2
  • Server: PHP.wasm
  • Database: WP_SQLite_Translator (Server: 5.5 / Client: 3.51.0)
  • Browser: Chrome 143.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Example Static 0.1.0
    • Test Reports 1.2.1

Steps to Reproduce

  • Clone gutenberg (using GitHub CLI) install dependencies and run dev scripts:
gh repo clone WordPress/gutenberg
cd gutenberg
npm install
npm run dev
  • Change to the changes in this PR's branch
gh pr checkout 74647
  • Launch create-block with current changes
npx ./packages/create-block
  • Press enter to accept default values
Let's customize your WordPress plugin with blocks:
✔ The template variant to use for this block: static
✔ The block slug used for identification (also the output folder name): example-static
✔ The internal namespace for the block name (something unique for your products): create-block
✔ The display title for your block: Example Static
✔ The short description for your block (optional): Example block scaffolded with Create Block tool.
✔ The dashicon to make it easier to identify your block (optional): smiley
✔ The category name to help users browse and discover your block: widgets
✔ Do you want to customize the WordPress plugin? No
  • Enter into example-static and launch a local WP (with latest version, currently WP 6.9) with the scaffolded plugin that registers the static block (using Playground's CLI tool)
cd example-static
npx @wp-playground/cli@latest server --auto-mount
  • Go to the URL the local WordPress is running (http://127.0.0.1:9400 for example), go to the admin (admin:password), edit any post and insert the Example Static block.

  • Save it and check is properly displayed online

  • Stop the previous process with CTRL+C and launch WP 6.7 with the scaffolded plugin that registers the static block

npx @wp-playground/cli@latest server --auto-mount --wp=6.7

You should get some errors indicating the WP version doesn't match the minimum version required by the plugin

Activating /wordpress/wp-content/plugins/example-static 99%Plugin /wordpress/wp-content/plugins/example-static activation printed the following bytes: <p><strong>Error:</strong> Current WordPress version (6.7.4) does not meet minimum requirements for Example Static. The plugin requires WordPress 6.8.</p>

Expected Results

  1. The plugin should work (and the block should be properly registered) for WP >= 6.8
  2. The scaffolded code for the block registration function should look like this
function create_block_example_static_block_init() {
	wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
}
add_action( 'init', 'create_block_example_static_block_init' );

Actual Results

  1. The plugin works (and the block is properly registered) for WP >= 6.8
  2. The scaffolded code for the block registration function looks like expected (see snippet above)

@juanmaguitar juanmaguitar removed the Needs Testing Needs further testing to be confirmed. label Jan 15, 2026
@jonathanbossenger
Copy link
Contributor Author

@jonathanbossenger Can you update the document as well?

@t-hamano will do 🫡

@jonathanbossenger
Copy link
Contributor Author

@t-hamano all instances of 6.7 updated.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@t-hamano t-hamano changed the title Simplify blocks-manifest registration Create Block: Simplify blocks-manifest registration Jan 20, 2026
@t-hamano t-hamano merged commit 891b0c5 into WordPress:trunk Jan 20, 2026
39 checks passed
@github-actions github-actions bot added this to the Gutenberg 22.5 milestone Jan 20, 2026
@jonathanbossenger jonathanbossenger self-assigned this Jan 20, 2026
adamsilverstein pushed a commit that referenced this pull request Jan 20, 2026
* Simplify blocks-manifest registration

Simplify's the code generated to register blocks in the main plugin file
to default to using the new wp_register_block_types_from_metadata_collection function.

Leaves the links to the update posts in the comments, so that developers building blocks
for older WordPress versions can make the nessecary changes manually.

* Update WordPress versions

Co-authored-by: jonathanbossenger <psykro@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Tool] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Block: Simplify blocks-manifest registration

5 participants