Show patterns in theme directory.#83
Show patterns in theme directory.#83StevenDufresne wants to merge 1 commit intoWordPress:trunkfrom StevenDufresne:try/patterns-in-directory
Conversation
|
I think all these ideas have merit. If we were to have a Patterns view from the Theme Preview page that could probably use a pattern grid too. |
|
On theme upload seems the most efficient, as long as that lifecycle runs every time a theme is changed. |
|
Note that themes can auto-register patterns by placing them in a |
Just noting, we don't have screenshots of patterns yet, and the image you shared uses the underlying control of the pattern preview control, without the controls.
Yep, new uploads and updates to themes are centralized. |

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 Previewsince 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.