Skip to content

Commit

Permalink
Update docs about wp-scripts build-blocks-manifest in relation to new…
Browse files Browse the repository at this point in the history
… WP 6.8 function. (#69445)
  • Loading branch information
felixarntz authored Mar 6, 2025
1 parent df7d1cc commit 6d2a915
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ This script uses [webpack](https://webpack.js.org/) behind the scenes. It’ll l
This script generates a PHP file containing block metadata from all
`block.json` files in the project. This is useful for enhancing performance
when registering multiple block types, as it allows you to use
`wp_register_block_metadata_collection()` in WordPress.
`wp_register_block_metadata_collection()` and
`wp_register_block_types_from_metadata_collection()` in WordPress.

Usage: `wp-scripts build-blocks-manifest [options]`

Expand Down Expand Up @@ -139,6 +140,20 @@ Using this approach can improve performance when registering multiple block
types, especially for plugins with several custom blocks. Note that this
feature is only available in WordPress 6.7 and later versions.

Alternatively, you can use `wp_register_block_types_from_metadata_collection()`
to have all block types from your plugin automatically registered in the same
function call. This way you no longer need to call `register_block_type()` for
every block type in your plugin.

```php
wp_register_block_types_from_metadata_collection(
plugin_dir_path( __FILE__ ) . 'dist',
plugin_dir_path( __FILE__ ) . 'dist/blocks-manifest.php'
);
```

Note that this feature is only available in WordPress 6.8 and later versions.

### `check-engines`

Checks if the current `node`, `npm` (or `yarn`) versions match the given [semantic version](https://semver.org/) ranges. If the given version is not satisfied, information about installing the needed version is printed and the program exits with an error code.
Expand Down

0 comments on commit 6d2a915

Please sign in to comment.