Introduce `pre_update_option` filter.
Filter is available in update_option() and allows to filter any option before its value is (maybe) serialized and updated. see #27504. props westonruter. Built from https://develop.svn.wordpress.org/trunk@27815 git-svn-id: http://core.svn.wordpress.org/trunk@27649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ebdd64f6ad
commit
bc8cf4e966
|
@ -255,6 +255,17 @@ function update_option( $option, $value ) {
|
||||||
*/
|
*/
|
||||||
$value = apply_filters( 'pre_update_option_' . $option, $value, $old_value );
|
$value = apply_filters( 'pre_update_option_' . $option, $value, $old_value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter 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 );
|
||||||
|
|
||||||
// If the new and old values are the same, no need to update.
|
// If the new and old values are the same, no need to update.
|
||||||
if ( $value === $old_value )
|
if ( $value === $old_value )
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue