[wp-trac] [WordPress Trac] #37930: Introduce a general `pre_option` filter in `get_option()`
WordPress Trac
noreply at wordpress.org
Wed Apr 19 15:35:58 UTC 2017
#37930: Introduce a general `pre_option` filter in `get_option()`
--------------------------------+------------------------------
Reporter: flixos90 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------------+------------------------------
Comment (by spacedmonkey):
Updated this patch with another solution. Consider the following code in
update_option
{{{#!php
$value = apply_filters( "pre_update_option_{$option}", $value,
$old_value, $option );
/**
* Filters an option before its value is (maybe) serialized and
updated.
*
* @since 3.9.0
*
* @param mixed $value The new, unserialized option value.
* @param string $option Name of the option.
* @param mixed $old_value The old option value.
*/
$value = apply_filters( 'pre_update_option', $value, $option,
$old_value );
}}}
It passes the value through both filters. I have updated my patch so
follow this patten. My patch passes the variable through the
pre_get_option second and uses the existing return.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37930#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list