In light of 4.1’s status as a short cycle release, I would propose a handful of changes to be made around meta to better prepare us for a future that is less dependent on /wp-admin/ and more dependant on APIs. These changes will pave the road for future enhancements to the WordPress mobile app, as well as any non-wp-admin interfaces we may encounter in the future.
What I would propose is:
1) We build wrapper functions for
Those wrappers would be:
These three wrapper functions would accept the following arguments:
post_type/term (string|array) (where appropriate)
The new item here would be
meta_format, which would accept a number of options out of the box:
1. short_text (text that would be collected by
2. long_text (text that would be collected by
6. image (this would be a field where an image is uploaded to the media library, and its ID stored in the
7. number (possibly could be either a string: ‘number’ or an array:
array( 'type' => 'number', 'decimal' => 2 ) )
8. select (would always be an array:
array( 'type' => 'select', 'values' => array( 'English', 'French', 'Spanish', ... ) ) )
Additional Meta formats could be added programmatically via a filter.
In addition, we would determine default sanitizations for data UNLESS EXPLICITLY OVERRIDDEN. So, for example,
short_text could be checked against wp_kses,
color would get checked to only allow 3 or 6 hex characters,
select would only allow strings defined in its declaration, dates would be re-formatted into YYYY-MM-DD, etc.
2) We announce that any interactions with undefined meta will be deprecated as of WordPress 4.5
Setting a fairly distant time horizon to allow developers plenty of time to update their themes and plugins.
3) Appropriate endpoints are added to the JSON REST API
Allowing application developers to obtain a list of meta definitions for every user/post/term, so that they can easily be modified through any future interface.
What do people think? I feel strongly that WordPress is in need of more powerful meta. We have the initial groundwork laid with
register_meta, but it lacks the concept of meta formats, which would propel us forward into the API age.