[wp-trac] [WordPress Trac] #43392: Support 'object' and 'array' types in register_meta()
WordPress Trac
noreply at wordpress.org
Tue Sep 17 08:59:34 UTC 2019
#43392: Support 'object' and 'array' types in register_meta()
-------------------------------------------------+-------------------------
Reporter: diegoliv | Owner:
| TimothyBlynJacobs
Type: enhancement | Status: reopened
Priority: normal | Milestone: 5.3
Component: Options, Meta APIs | Version: 4.9.4
Severity: normal | Resolution:
Keywords: has-unit-tests dev-feedback commit | Focuses: rest-api
needs-dev-note has-patch needs-docs |
-------------------------------------------------+-------------------------
Changes (by grapplerulrich):
* keywords: has-patch has-unit-tests dev-feedback commit needs-dev-note =>
has-unit-tests dev-feedback commit needs-dev-note has-patch needs-docs
Comment:
Ok, I was able to prevent the PHP notice by changing the code to the
following:
{{{#!php
register_meta(
'post',
'swisscomkbw-authors',
[
'type' => 'array',
'single' => true,
'show_in_rest' => [
'schema' => [
'type' => 'array',
'items' => [
'type' => 'string',
],
],
],
]
);
}}}
This means the documentation for `show_in_rest` in `register_meta()` needs
to be updated too to mention that both booleans and arrays are supported.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43392#comment:49>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list