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

WordPress Trac noreply at wordpress.org
Mon Apr 11 22:45:38 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 rest-api                                 |     Focuses:
-------------------------------------------------+-------------------------

Comment (by ericlewis):

 @jeremyfelt thank you for starting the fire here.

 I have some ideas in attachment:35658.2.diff:

 * Let's introduce something like `class WP_Meta_Manager` to store state of
 what is registered and what isn't. This guards us from developers
 accessing (and modifying) public global arrays.
 * I've moved the business logic of some registry-related functions into
 it, and left the global functions as wrappers for them
 (`registered_meta_key_exists()` and `unregister_meta_key()`)

 Follow-up thoughts:

 * Should the JSON data type value represent the entire JSON schema type
 attributes (items, properties, etc.) a la
 {{{
 #!php
 register_meta_data(
         'review',
         'post',
         array(
                 'json_data_type' => array(
                         'type' => 'array',
                         'items' => array(
                                 'type' => 'array',
                                 'items' => array(
                                         'type' => 'object',
                                         'properties' => array(
                                                 'reviewer_name' => array(
                                                         'type' => 'string'
                                                 ),
                                                 'review' => array(
                                                         'type' => 'string'
                                                 )
                                         )
                                 )
                         ),
                         // No minimum or maximum.
                         // 'minItems' => 0,
                         'maxItems' => 1
                 )
         )
 );
 }}}

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


More information about the wp-trac mailing list