Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've opened up this PR as a place for discussion on https://meta.trac.wordpress.org/ticket/5995. While this PR comes with code updates, it's purely experimental and not necessarily the best implementation or experience. I would have preferred to use an issue but they are closed for this repository and having the discussion in trac feels a bit limiting.
Assumption
It would be helpful for users to be able to preview patterns that are bundled with themes in the theme directory.
Details
How can we detect patterns?
Static code analysis
register_block_pattern
(JS, PHP)theme.json
(Link)/patterns
(Link)Dynamic analysis (with running environment)
wp.data.select('core').getBlockPatterns()
(Link)WP_Block_Patterns_Registry::get_all_registered()
(Link)When can we detect patterns?
class-wporg-themes-upload.php
(Static) (Link)... store results in meta for
repopackage
...Theme Preview
since it has a running environment when the user interacts with it.Where could we show patterns?
Theme Directory
Ideas
The theme directory is likely to undergo a redesign in the next year or so. If we want to get something up before that completes, which probably makes sense, we should aim to make the most minimal changes.
Directory View
We could add Icons to the theme tile to denote that a theme bundles patterns.
Single Theme View
We can add a section below the tags. It could be a list of the pattern names or could also use pattern directory previewer. If so, It would have to have some sort pagination control experience since some themes bundle 10+ patterns.
Theme Preview
What if we give a navigation item that users can click that loads a dynamically generated page with all the patterns? I've added blocks to the menu just as an example.