mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 06:37:06 +00:00
REST API: Support meta registration for specific object subtypes.
Introduce an `object_subtype` argument to the args array for `register_meta()` which can be used to limit meta registration to a single subtype (e.g. a custom post type or taxonomy, vs all posts or taxonomies). Introduce `register_post_meta()` and `register_term_meta()` wrapper methods for `register_meta` to provide a convenient interface for the common case of registering meta for a specific taxonomy or post type. These methods work the way plugin developers have often expected `register_meta` to function, and should be used in place of direct `register_meta` where possible. Props flixos90, tharsheblows, spacedmonkey. Fixes #38323. git-svn-id: https://develop.svn.wordpress.org/trunk@43378 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -27,6 +27,17 @@ class WP_REST_Comment_Meta_Fields extends WP_REST_Meta_Fields {
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the object meta subtype.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @return string 'comment' There are no subtypes.
|
||||
*/
|
||||
protected function get_meta_subtype() {
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the type for register_rest_field() in the context of comments.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user