As announced yesterday, there was a discussion today covering the future of register_meta()
, something that has been in progress for WordPress 4.6 in #35658. This is a recap. 🙂
Attendees: @helen, @ocean90, @rachelbaker, @mikeschinkel, @jsternberg, @sc0ttclark, @richardtape, @swissspidy, @joemcgill, @seancjones, @achbed, @jeremyfelt
Chat log.
Overview
In #35658, register_meta()
uses object subtypes when registering meta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. so that key registration can be considered unique.
In 4.6 trunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision., this information is passed as part of the 3rd argument—array( 'object_subtype' => 'books' )
—to register_meta()
and $object_subtype = ''
has been added as an extra argument to several other pieces as a way to support that.
After exploring a bit more, it’s clear that $object_subtype
will continue to spread as an additional argument throughout many _meta()
functions so that registered meta is handled properly.
An alternative is to use CURIEs to describe complex meta types in a single string—'comment:reaction'
rather than 'comment'
and 'reaction'
—so that the extra argument is not needed. Instead, processing exists to turn that string into an object type and subtype.
Examples
post:post
post:books
term:category
user:user
comment:reaction
The main question for today’s discussion
Is CURIE like notation the right way forward for handling complex meta types?
Decisions
After a very good and thorough conversation about the above and other points, these are the decisions for moving forward with work on #35658:
- Meta keys will be registered using CURIE like syntax.
register_meta( 'post:book', 'isbn', $args );
- The
:
used in the string to register meta keys will also be used in filters.
sanitize_post:book_meta_isbn
- Core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. object types will fallback to default subtypes if one is not specified.
- post becomes post:post, comment becomes comment:comment, user becomes user:user, and term becomes term:category The 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging..
- Meta key registration for all/any subtypes of an object type will not be included in 4.6, but is likely something to add in the future.
Please check out the latest patches on #35658 and contribute code and thoughts on that ticket Created for both bug reports and feature development on the bug tracker. or share any questions/concerns in the discussion below.
Thanks everyone for attending today!
#4-6, #options-meta