Generally, I’m very supportive of adding more structured metadata around data in WordPress. I’m also not a huge fan of P2 discussion threads (because P2 kinda sucks), so keep that in mind if I forget to reply to a comment / don’t get an email notification about a comment.

I think we should follow JSON Schema unless we make a deliberate, and intentional, reason not to. Following JSON Schema gives us access to all of the validation libraries already written, clients that can interpret it, etc. etc. Not following JSON Schema invents even more work for us, makes WP incompatible with existing tools that use JSON Schema, means we have to create a translation layer between this and the WP REST API, etc. etc. The mock code provided appears to mostly follow JSON Schema with a few unintentional (?) departures.

More specifically, type should always be one of a fixed set of values. The wp-image type would be more correctly expressed as type=>integer,format=>wp-image. Or, we could define our own relation attribute.

The options attribute has an equivalent in JSON Schema: enum

Lastly, repeatable appears to be functionally equivalent to type=>array,items=>.... I suppose we could include it as a utility attribute, but doing so adds complexity.


Also worth mentioning: the problem of defining an application’s data models is one I’m sure many other CMSes, frameworks, etc. have worked on. It would be really good to apply their learnings and (try to) avoid their mistakes.

From "A data schema for meta", aka a very important conversation on WordPress architecture.

Hand Built is Daniel Bachhuber, an effective developer with technology leadership you can trust.

How can I help?

Hit me at [email protected] with a short note about what you'd like to do.

My roots are WordPress and publishing, and I love pretty much everything related to web development (architecture, performance, security, etc.). When not working with clients, I also maintain WP-CLI (WordPress' command line interface) and other open source projects.

Want to connect? I'm on Twitter, Github and LinkedIn. Or, sign up for my TinyLetter for periodic newsletters.