[wp-trac] [WordPress Trac] #43941: Add default value to register meta
WordPress Trac
noreply at wordpress.org
Mon Sep 23 18:05:40 UTC 2019
#43941: Add default value to register meta
--------------------------------------+-----------------------------
Reporter: spacedmonkey | Owner: spacedmonkey
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future Release
Component: Options, Meta APIs | Version: 4.6
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: rest-api
--------------------------------------+-----------------------------
Comment (by TimothyBlynJacobs):
Uploaded a patch to support a `null` default type as discussed in last
week's office hours. I don't think supporting `null` is a blocker, but
it'd be a bit difficult to patch in later due to the args filter in
`register_meta` and `null` would be the best default for a `date-time`
meta type that is optional.
{{{#!php
<?php
register_meta( 'post', 'my_date', array(
'type' => 'string',
'show_in_rest' => array(
'type' => array( 'string', 'null' ),
'format' => 'date-time',
),
) );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43941#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list