WordPress / pattern-directory

The WordPress Block Pattern Directory
https://wordpress.org/patterns/
GNU General Public License v2.0
121 stars 34 forks source link

Handle changing pattern category names #532

Open ryelle opened 1 year ago

ryelle commented 1 year ago

See https://github.com/WordPress/gutenberg/issues/44501, https://github.com/WordPress/gutenberg/pull/44203

The pattern categories are being rethought, so the names will be changing. The Pattern Directory provides patterns for multiple WP versions, but the categories themselves are hardcoded into each version. If the names update, sites who aren't using the latest Gutenberg would get a bunch of Uncategorized patterns.

This came up with the Banner category, where it was deemed OK, but if we're changing multiple categories that seems like a bad experience.

ryelle commented 1 year ago

"Query" will be changed to "Posts" when GB 14.5 is released, so w.org/patterns will need a solution for then

ref https://github.com/WordPress/gutenberg/pull/45244

ntsekouras commented 1 year ago

In my mind, we can create a mapper for previous category names with new ones and swap them while we show them in different parts of the UI. I haven't tested anything yet, but seems simple enough and similar to the blocks renaming handle we have, like the renamed embed or social blocks that got merged under one main block with variations.

ryelle commented 1 year ago

That sounds like a good way for Gutenberg to handle older plugins/themes that register blocks with the old labels 👍🏻

For WP sites that aren't using Gutenberg (so just plain WP 6.1), if we update the categories for the Core & Featured patterns, they won't have those new categories. For example, a pattern that used to be "buttons" is now "call to action", but the non-GB site doesn't know "call to action". Is it OK that these will be "Uncategorized"? I suppose it's only 8 patterns that are "core" but not "featured", and the rest of the "featured" ones would stay in the Featured category.

Edit: Maybe this won't be necessary, waiting on some feedback from #190

ntsekouras commented 1 year ago

For WP sites that aren't using Gutenberg (so just plain WP 6.1), if we update the categories for the Core & Featured patterns, they won't have those new categories.

I'm not sure I get the problem.. Is it about the pattern creation UI in the directory? If yes, shouldn't a similar mapping in PD solve this as well? For example show in the UI, the new category, but during creation also add the old one. In WP sites now it will be shown only to the categories that are registered, depending on the usage of GB or not.