[wp-trac] [WordPress Trac] #35658: Provide additional data for registered meta through register_meta()
WordPress Trac
noreply at wordpress.org
Fri Jan 29 15:35:46 UTC 2016
#35658: Provide additional data for registered meta through register_meta()
------------------------------------------+------------------------------
Reporter: jeremyfelt | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------------------
Comment (by jeremyfelt):
Results of some more discussion around this:
* We'll need to start using a `$wp_meta_keys` global to track registered
meta keys.
* Uniqueness is important. A meta key can technically exist for multiple
types objects (post, comment, user, term) as well as types of those types
of objects—custom post types. The global array should track these uniquely
so that a proper JSON Schema can be output.
It's possible the first argument of `register_meta()` should be an array:
{{{
$args = array(
'post' => array( 'post', 'cpt-one', 'cpt-two' ),
'term',
);
register_meta( $args, 'my_meta_key', 'my_sanitize_callback' );
}}}
The third argument should be an array as well (as @swissspidy just
mentioned):
{{{
$object_args = array(
'post' => array( 'post', 'cpt-one', 'cpt-two' ),
'term',
);
$args = array(
'rest_data_type' => 'string',
'rest_description' => 'A description of this meta for the JSON
Schema',
'sanitize_callback' => 'my_sanitization_callback',
);
$register_meta( $object_args, 'my_meta_key', $args );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35658#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list