[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:13:46 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:49 knutsp]:
 > I suggest adding 'bool' as alias of 'boolean' and 'int' as alias of
 'integer' for `$value_type`

 Yea, was wondering if it's worth supporting these shorthand "type names".
 Generally `wp_get_db_value_types()` is modeled after PHP's `settype()`, so
 maybe it makes sense to allow the short names and not be too "strict". We
 don't even have to add "translations" as `settype()` accepts `bool` and
 `int`, see https://www.php.net/manual/en/function.settype.php.

 Not so sure about "double" (the old name for a decimal number). Also note
 that the REST API doesn't understand "float" and uses "number" instead.
 Unfortunately that is also the case for `register_meta()` and
 `register_setting()` :(

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


More information about the wp-trac mailing list