Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern CPT & API: Add block types meta field #111

Merged
merged 1 commit into from
May 21, 2021
Merged

Conversation

ryelle
Copy link
Contributor

@ryelle ryelle commented May 21, 2021

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 to http://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:

  1. Add a custom field called wpop_block_types to a pattern. The value must be a block type name, formatted like namespace/name - it should strip any non-alphanumeric characters out (allowing / and -).
  2. GET /wp-json/wp/v2/wporg-pattern/[ID] — the meta value should include the value you entered.
  3. GET /wp-json/wp/v2/wporg-pattern/ — all patterns should have a meta.wpop_block_types value, defaulting to empty array.

Try adding various values to the meta field, add multiple, etc.

@ryelle ryelle added the [Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint label May 21, 2021
@ryelle ryelle added this to the Initial Launch milestone May 21, 2021
@ryelle ryelle requested review from iandunn and tellyworth May 21, 2021 18:49
@ryelle ryelle self-assigned this May 21, 2021
Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few questions, but fine to merge as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants