WordPress 6.1 introduces new features and updates to the
@wordpress/create-block package used by developer to scaffold new blocks.
Block Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. Variants
--variant flag allows users of the tool to choose a block variant to be scaffolded. The internal templates provided by the create-block package support a
static variant with will scaffold a dynamic and static block respectively. If no variant is passed, the
static variant is used.
Scaffolding using the dynamic variant:
npx @wordpress/create-block custom-block --variant=dynamic
Template authors can define variants by adding a
variants object to the template definition with each property being the name of a variant and its value an object containing values that can add to or overwrite the default values defined in the
defaultValues key. See the create-block-tutorial-template file for an example of defining variants.
Related pull requests: #41289, #43481.
Add additional blocks to an existing plugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party
A highly requested feature for the package was to be able to add additional blocks to an existing plugin. With the addition of the
--no-plugin flag that is now possible!
When the command is run with the flag, the tool creates a new set of block files in a subdirectory to the current directory named with the slug passed.
npx @wordpress/create-block custom-block --no-plugin
Related pull requests: #41642.
- I18n Internationalization, or the act of writing and preparing code to be fully translatable into other languages. Also see localization. Often written with a lowercase i so it is not confused with a lowercase L or the numeral 1. Often an acquired skill. references have been removed from the internal templates to avoid potential issues with translated strings causing block validation errors ( #43035 )
- Improvements to the developer experience by prompting to continue the scaffolding process if the tool thinks system requirements are not met ( #42151, #42254 ) and some more general fixes to the scaffold to remove some warnings and errors ( #40479, #41273 ).
- Adds support for the new
The documentation around creating External Templates has been split into a separate section ( #43718 ) and links to the documentation in the associated create-block-tutorial-template have been fixed to link to the correct places ( #42839 ).
Direct links to all documentation pages for the
create-block scaffolding tool:
Props @pbiron, @bph for review