[wp-trac] [WordPress Trac] #43392: Support 'object' and 'array' types in register_meta()
WordPress Trac
noreply at wordpress.org
Thu Sep 12 07:26:06 UTC 2019
#43392: Support 'object' and 'array' types in register_meta()
-------------------------------------------------+-------------------------
Reporter: diegoliv | Owner:
| TimothyBlynJacobs
Type: enhancement | Status: closed
Priority: normal | Milestone: 5.3
Component: Options, Meta APIs | Version: 4.9.4
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests dev- | Focuses: rest-api
feedback commit needs-dev-note |
-------------------------------------------------+-------------------------
Comment (by grapplerulrich):
@kadamwhite Thank you very much for committing this. I have ended up
backporting this commit for WP 5.2.x so that I can use this feature before
5.3 is released.
Though I got a PHP notice:
{{{
Undefined index: items in wp-includes/rest-api/fields/class-wp-rest-meta-
fields.php on line 554
}}}
https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-
api/fields/class-wp-rest-meta-fields.php#L554
I think the reason for this PHP notice is that `items` is not defined in
`$default_schema` in `get_registered_fields()`.
My code that I used:
{{{#!php
<?php
\register_meta(
'post',
'swisscomkbw-authors',
[
'show_in_rest' => true,
'single' => true,
'type' => 'array',
]
);
}}}
The inline documentation still needs to be updated for the support or
arrays and objects in `register_meta()`
https://github.com/WordPress/WordPress/blob/master/wp-
includes/meta.php#L1126-L1127
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43392#comment:45>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list