[wp-trac] [WordPress Trac] #55942: Add a "value type" parameter to get_option() and get_metadata()

WordPress Trac noreply at wordpress.org
Wed May 3 12:49:31 UTC 2023


#55942: Add a "value type" parameter to get_option() and get_metadata()
-------------------------------------------------+-------------------------
 Reporter:  azaozz                               |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  6.3
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing                                        |  performance
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 Replying to [comment:52 azaozz]:
 > Replying to [comment:50 spacedmonkey]:
 > > Register meta existing before the REST API
 >
 > Right, but there was a pretty major upgrade for it in WP 5.5 that
 changed a lot of stuff (and made some weird assumptions), see #43941.

 That was my ticket, I worked on it months. What assumptions were weird
 there? Can you provide any detail?

 The types supported are the following

 'string' - string
 'boolean' - boolean
 'integer' - integer
 'number' - float / double
 'array' - array
 'object' - object

 Barring number, which IMO, is just a float value, all those types make
 sense to me. There is even help functions like
 `rest_sanitize_value_from_schema` and `rest_validate_value_from_schema`
 that will happen the validation and schema handling for you.

 I am really against adding new parameter to the signatures of meta and
 options functions and believe we should explore register_meta and
 register_settings.

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


More information about the wp-trac mailing list