Opened 7 weeks ago
Last modified 6 weeks ago
#64123 new enhancement
Patterns: add the pattern name to pattern blocks when they are converted
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Editor | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
The editor has used metadata in pattern attributes since https://github.com/WordPress/gutenberg/pull/59251 to organize and sort patterns.
Patterns metadata allows the editor to distinguish patterns from other block groups, and from other patterns.
An initiative to introduce a special "simple" content only mode to patterns depends on this feature. For user-created and inserted patterns, the editor will render the block tree differently, and present specific controls and tools to the user.
See: See: https://github.com/WordPress/gutenberg/issues/71517
The feature is slated for WordPress 7.0.
For this feature to work however, the block editor needs to know that it is dealing with a pattern.
For patterns created in the editor, and for patterns returned by the patterns REST API endpoint, the status of "pattern" can be inferred.
However, many templates contain patterns, for example TT5's 404 template
The block editor could parse templates on the frontend to identify patterns upon insertion, but this would have an impact on performance, especially for large patterns.
Rather, let's leverage the existing patterns parser resolve_pattern_blocks to add this metadata to theme patterns before they're sent as a response from the REST APIs.
See: https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/blocks.php#L1843
Change History (5)
This ticket was mentioned in PR #10248 on WordPress/wordpress-develop by @ramonopoly.
7 weeks ago
#1
@scruffian commented on PR #10248:
6 weeks ago
#2
Is there other metadata we could/should add to patterns - some of them seem to also contain a longer description. It would be good to support as much metadata as possible IMO.
@ramonopoly commented on PR #10248:
6 weeks ago
#3
Is there other metadata we could/should add to patterns - some of them seem to also contain a longer description. It would be good to support as much metadata as possible IMO.
Good question. What do you think the editor might need? There are also optional categories and block types, which could come in handy if the editor ever wanted to extend "change design" to patterns bundled with templates.
I'm not sure.
@scruffian commented on PR #10248:
6 weeks ago
#4
The description would be useful for https://github.com/WordPress/gutenberg/pull/72574. Not sure about the others.
@ramonopoly commented on PR #10248:
6 weeks ago
#5
The description would be useful for https://github.com/WordPress/gutenberg/pull/72574.
Done!
Builds upon https://github.com/WordPress/wordpress-develop/pull/10180
Props to @scruffian
Modifies the
resolve_pattern_blocksfunction to include metadata for single-root patterns, allowing the pattern name and title to be stored in the block attributes. The metadata contains thepatternNameandnameattributes.This enables identification of patterns inside templates and allows for special treatment in the editor.
This will be used to test contentOnly editing (https://github.com/WordPress/gutenberg/issues/71517), so that themes that use patterns automatically opt into this behaviour.
Trac ticket: https://core.trac.wordpress.org/ticket/64123