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.
Still mostly an experiment but it's working pretty well; I've been using it for (not.. in.. but for) production for a bit now.
This change adds pattern management to CBT: Both for Synced and Unsynced patterns.
With this plugin loaded Any pattern (that has Inserter: true) that is in the theme's "/patterns" folder is UN-registered. It's then made available to the Site Editor, posing as a User Created pattern (which can be edited). When the user saves the pattern the pattern file is updated (instead of the database). Any User-created unsynced patterns are saved as a file when you "Save Changes to Theme". Boom. Pattern Management.
But wait there's more.
If you create SYNCED patterns then THOSE get written to the /patterns folder too. There is an additional "Synced: true" flag saved in their file. When those patterns are loaded (and CBT is activated) then the content of those patterns are copied to the database.
There's a little snippet of code that can go along with the themes exported with these patterns that allows them to continue to be loaded as synced patterns. HOWEVER it's not necessary; if CBT is inactive and the snippet is absent the patterns will just load as unsynced patterns.
The REASON that doesn't cause problems is because none of the patterns and templates that use these synced patterns actually REFERENCE them as blocks
<!-- wp:block {ref:123} /-->
but instead by a pattern slug
<!-- wp:pattern {slug:SLUG} /-->
When CBT loads the "synced" patterns it registers an "unsynced" pattern with the content
<!-- wp:block {ref:123} /-->
.This allows you to fully manage your patterns, USE them in templates (and other patterns!) and then SAVE your theme, with all of your patterns safely packed inside.
To Test