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

WordPress Trac noreply at wordpress.org
Thu May 4 22:57:45 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:67 flixos90]:

 > * If we put a new parameter on `get_option()` for the type, that's a
 clunky API: A single option may be retrieved in several places. Having to
 remember in every single function call to put the right `$type`...

 I tend to disagree. This doesn't sound like a problem. If you can remember
 (copy) the option name, you certainly can remember (copy) the type and
 eventually the default walue too :)

 > * Using `register_setting()` is more appropriate

 Not sure about that. `register_setting()` is (was?) intended for use in
 the UI. Not for the low level options and meta.

 > I think we need a central function to control this

 Hmmm, thinking that having to use two different pieces of code just to set
 an option or meta would probably be quite "clunky". I understand that now
 the REST API requires this, but not sure if that's the best way to do it
 especially for the low level data/interactions with the DB.

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


More information about the wp-trac mailing list