Register fields to Wordpress internals
Issue Overview
WP allows register meta fields in similar way as is for PostType or Taxonomy. Main difference is that it doesn't have as many as functions as MetaBox, but it is more or less standardized workflow to define post/term/etc fields.
Most MetaBox can be reinitialized with WP functions https://developer.wordpress.org/reference/functions/register_meta/ or shortcut functions for posts or terms https://developer.wordpress.org/reference/functions/register_post_meta/ https://developer.wordpress.org/reference/functions/register_post_meta/
With sanitizing, name + description (as description field), multiple (single as false) and clone (object or array type) support or clone_as_multiple (single false + object type).
Expected Behavior
Developer can use built-in functions as https://developer.wordpress.org/reference/functions/get_registered_meta_keys/ and all related functions.
Current Behavior
WP doesn't any clue except MetaBox about registered meta fields.
Possible Solution
As Extensions module to MetaBox, no needed in core.
@radeno I read about this meta functions, but to be honest, I didn't find any usage of them. Do you have any example?
Not really. But it looks like WP moving from CMS to CMF (what is good). Define functional data blocks (post types, taxonomies and meta fields) and let community to offer UI/UX based on it.
register_metadata makes easier integration with Gutenberg mostly. But it is not limited just to Gutenberg, because it exposes fields to REST API with all CRUD actions.
Thanks for the details. That sounds a good reason to implement this!
Yep it is. But it depends which fields/field types are compatible. Maybe in this issue could be defined schema definitions for each field types.
Hi @rilwis, just curious here. Did something change in regards to this feature request? It would be very interesting for a project I'm consulting on if this plugin offered direct integration with the internal metadata functionality.
Would be nice if there was a way to use the custom fields and relations defined by this plugin, register them with WP using register_meta and even map them to the correct JSON Schema (for validation etc). I don't think this is currently implemented in the REST API Add-on, but I can be mistaken, of course.
Hi @vdwijngaert ,
This hasn't been implemented in the plugin. Currently, for using fields with REST API, the MB REST API plugin is enough.
Would you like to contribute to the plugin with this feature?