[wp-trac] [WordPress Trac] #35658: Provide additional data for registered meta through register_meta()

WordPress Trac noreply at wordpress.org
Tue Feb 2 13:01:35 UTC 2016

#35658: Provide additional data for registered meta through register_meta()
 Reporter:  jeremyfelt                           |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Options, Meta APIs                   |  Review
 Severity:  normal                               |     Version:
 Keywords:  needs-unit-tests needs-testing has-  |  Resolution:
  patch                                          |     Focuses:

Comment (by tharsheblows):

 It's very possible I'm entirely misunderstanding this, apols, so is this
 what you're thinking for serialized data? If I have this as a meta value
 for the user_details_array meta key:
 $meta_value = array(
  'name' => 'Bob',
  'age' => 63,
  'email' => 'bob at example.com'

 I could register it with the data type something like
 $data_type = array(
   'array' => array(
     'name' => 'string',
     'age' => 'number',
     'email' => 'string' )

 which would be used to sanitize and validate (in addition to custom
 callbacks?)  and put in the schema something kind of like this?
 "user_details_array": {
   "type": "array",
   "properties": {
     "name" : { "type": "string" },
     "age" : { "type": "number" },
     "email" : { "type": "string" }
 Then when I went to update it, it would check against the schema and give
 me an error if I, eg, tried to change it to an object without changing the
 registered_meta data. There would also be a sensible default type for the
 array / object items (probably "string") so I could just use `'data_type'
 => 'array'` when registering the meta key and it'd still work. But I would
 be required to state the data type if I wanted to use serialized data.

Ticket URL: <https://core.trac.wordpress.org/ticket/35658#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list