Opened 8 years ago
Last modified 10 months ago
#37928 new enhancement
add `pre_add_option` filter
Reported by: | flixos90 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | has-patch needs-refresh |
Focuses: | Cc: |
Description
get_option()
and update_option()
already have filters to short-circuit their respective processes, so I think a similar filter should be added to add_option()
as well.
Attachments (2)
Change History (10)
#3
follow-up:
↓ 4
@
8 years ago
I would prefer to have a separate filter to allow a short-cicuit instead of abusing a return value to imply such a behaviour.
And a random value really sounds like a terrible idea :)
#4
in reply to:
↑ 3
@
8 years ago
- Keywords needs-refresh added
Replying to jipmoors:
I would prefer to have a separate filter to allow a short-cicuit instead of abusing a return value to imply such a behaviour.
Definitely makes sense. I patched this way too quickly. :)
#5
@
8 years ago
37928.2.diff adds a dedicated filter to short-circuit the process of adding an option.
37928.diff is a first take on introducing the filter. I used
null
as a return value to skip sincenull
is very unlikely to be stored as option. However, it is not a perfect solution I think. I was wondering whether it might make sense to declare aWP_DEFAULT_VALUE
constant, fill it with some random value, and use that in such cases.