-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add the pattern name to pattern blocks when they are converted #10180
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
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@scruffian Address PHPCS and unit test issue |
Thanks for looking. At the moment this is really just being used to prototype an experience in Gutenberg. If we decide its a good idea then we'll need to return to the code and make it work in a more expected way, fix the tests and the PHPCS issue etc. |
ramonjd
left a comment
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.
Trim whitespace from pattern content before parsing blocks to prevent block parser creating a "freeform" block for any remaining content. Constrain to single root-block patterns
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
|
Added some unit tests in #10248 🤞🏻 |
|
This is testing well for me as well, I tested alongside the gutenberg contentOnly patterns experiment. It was interesting to test some of the Starter Content / Full Page patterns. A concern I had is that they'd be inserted as a single pattern, but it actually works well. They tend to be made up of multiple root patterns (e.g. https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-content/themes/twentytwentyfive/patterns/page-landing-book.php), so I still do wonder if we might need a way to exempt some patterns from |
Do you mean based on pattern content? Or some opt-out mechanism? I think, if there is to be a way to opt out, I think it should be editor-based since that's where the feature manifests itself. I don't know how that would look (user driven or using some logic based on the pattern/template itself). The alternative could be an opt-out flag in the pattern object/metadata or theme.json, but I reckon that could lead us into the spider's web. E.g.,
No need to consider any of these points, I'm just arguing with myself 😄 |
An opt-out per pattern in the metadata. Maybe opt-out is the wrong term, but instead a way to skip applying the patternName to a pattern wrapper block. An example use case, if any of those page patterns had multiple I don't think there would be any issue with an opt-out like that, the result would be the same as for page patterns that have no single wrapper, the inner However, I think it's also too early to think about these things at the moment, and there are currently no examples of patterns that don't work, so best not to over-optimize. |
|
Is it okay if we move this to #10248? I've created tests and a trac ticket. |
|
Closing in favour of #10180 |


This adds the
metadataattribute to the outermost wrapping block when a pattern is converted to blocks. The metadata contains thepatternNameandnameattributes.This will be used to test contentOnly editing (WordPress/gutenberg#71517), so that themes that use patterns automatically opt into this behaviour.