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

WordPress Trac noreply at wordpress.org
Fri Apr 28 21:38:10 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 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.

 > I think these functions were designed to do exactly this. They are
 currently used only for the REST API, but this another perfect use for
 them.

 Yep, and with updating the underlying (lower level) meta and options APIs,
 this becomes even easier.

 Unfortunately when `register_meta()` and `register_setting()` were added
 or updated to support the REST API, they were made slightly incompatible
 with the PHP data types. There is no `number` type in PHP. There will have
 to be some "type name translation".

 Ideally that translation should have happened in the REST API, however the
 `register_meta()` and `register_setting()` also accept that type, so...
 Not sure what would be good here.

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


More information about the wp-trac mailing list