-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update block-patterns.md #27655
Update block-patterns.md #27655
Conversation
In the new WordPress 5.6, it is required to have a 'categories' property in the register_block_pattern function.
@youknowriad, can you review this changes proposed? I couldn't find the place in the code where categories for block patterns would be enforced. |
I think we should investigate where categories became required. If it wasn't the case in previous versions, this might be a bug we need to fix. |
@@ -23,6 +23,7 @@ register_block_pattern( | |||
'my-plugin/my-awesome-pattern', | |||
array( | |||
'title' => __( 'Two buttons', 'my-plugin' ), | |||
'categories' => array( 'my-plugin' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the Pull Request!
The value(s) inside the categories array needs to be an existing block pattern category.
Although 'my-plugin' could be its own block category, a custom block pattern needs to be registered first and for the sake of simplicity for this documentation; we should use one of the default categories, which would be buttons.
And then wrap it in a translation function, because buttons can mean some different context, so it would look like:
'categories' => array( _x( 'buttons', 'Block pattern category', 'my-plugin' )),
The block editor would crash if the categories was not included - #27249; From testing, requiring the categories value was introduced sometime between 9.0.0 and 9.1.0 . |
Thank you for reporting this! This was a bug in Gutenberg (categories are not required for a block pattern) and has been fixed in #27970 and will be added to WordPress 5.7 so the documentation does not need to be updated. |
In the new WordPress 5.6, it is required to have a 'categories' property in the register_block_pattern function.
Description
How has this been tested?
Screenshots
Types of changes
Checklist: