Opened 9 years ago
Last modified 7 months ago
#37928 new enhancement
add `pre_add_option` filter
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Options, Meta APIs | Keywords: | has-patch |
| 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 (12)
#3
follow-up:
↓ 4
@
9 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
@
9 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
@
9 years ago
37928.2.diff adds a dedicated filter to short-circuit the process of adding an option.
This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.
9 years ago
This ticket was mentioned in PR #9229 on WordPress/wordpress-develop by @sainathpoojary.
7 months ago
#9
- Keywords needs-refresh removed
Trac ticket: #37928
37928.diff is a first take on introducing the filter. I used
nullas a return value to skip sincenullis 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_VALUEconstant, fill it with some random value, and use that in such cases.