Pattern CPT & API: Add block types meta field #111
Merged
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.
See #33 — this adds a meta field for block types, which is exposed in the API as
meta.wpop_block_types
. This is an array of block type names. Once this is added to the CPT and deployed, it will become available tohttp://api.wordpress.org/patterns/1.0/
. A corresponding PR will be made in gutenberg to add support to the/__experimental/pattern-directory/patterns
endpoint.I went with a meta field for now, since it can easily be set (in UI or WP-CLI) for the existing core patterns, and doesn't need the full infrastructure of a taxonomy. If we decide once building the UI that a taxonomy makes more sense, we can write a script to convert the post meta (but I think meta will be the way to go).
How to test the changes in this Pull Request:
wpop_block_types
to a pattern. The value must be a block type name, formatted likenamespace/name
- it should strip any non-alphanumeric characters out (allowing / and -).meta.wpop_block_types
value, defaulting to empty array.Try adding various values to the meta field, add multiple, etc.