[wp-trac] [WordPress Trac] #55942: Add a "value type" parameter to get_option() and get_metadata()
WordPress Trac
noreply at wordpress.org
Fri May 5 16:13:48 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:67 flixos90]:
> * Using `register_setting()` is more appropriate from that concern's
perspective, however it also has several other side effects. Certainly, we
should not use the existing `type` field of that function since that is
heavily used already, and if that suddenly would define what
`get_option()` returns, that would be a backward compatibility break.
If we were to use `register_setting()` and reuse the type, there would
need to be an opt-in. Like a new parameter, like `strict_typing` or
similar. If a developer opt-in, only then does it force the fixed typing.
> 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 value too :)
This imply that you are using your own option doesn't it. What if you are
using a option from a plugin written by another developer. What if that
developer changes the value from a string to a boolean when updating the
plugin. No, if we are going to do this, types need to be defined in one
place. Register settings is the logical place for that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55942#comment:69>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list