Add a pre_set_theme_mod_$name filter to set_theme_mod().
This is modeled after pre_update_option_$option in update_option() and pre_set_transient_$transient in set_transient(). props obenland. fixes #14721. Built from https://develop.svn.wordpress.org/trunk@27393 git-svn-id: http://core.svn.wordpress.org/trunk@27241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2c68373c83
commit
4c7c24ecbf
|
@ -913,8 +913,21 @@ function get_theme_mod( $name, $default = false ) {
|
||||||
*/
|
*/
|
||||||
function set_theme_mod( $name, $value ) {
|
function set_theme_mod( $name, $value ) {
|
||||||
$mods = get_theme_mods();
|
$mods = get_theme_mods();
|
||||||
|
$old_value = $mods[ $name ];
|
||||||
|
|
||||||
$mods[ $name ] = $value;
|
/**
|
||||||
|
* Filter the theme mod value on save.
|
||||||
|
*
|
||||||
|
* The dynamic portion of the hook name, $name, refers to the key name of
|
||||||
|
* the modification array. For example, 'header_textcolor', 'header_image',
|
||||||
|
* and so on depending on the theme options.
|
||||||
|
*
|
||||||
|
* @since 3.9.0
|
||||||
|
*
|
||||||
|
* @param string $value The new value of the theme mod.
|
||||||
|
* @param string $old_value The current value of the theme mod.
|
||||||
|
*/
|
||||||
|
$mods[ $name ] = apply_filters( "pre_set_theme_mod_$name", $value, $old_value );
|
||||||
|
|
||||||
$theme = get_option( 'stylesheet' );
|
$theme = get_option( 'stylesheet' );
|
||||||
update_option( "theme_mods_$theme", $mods );
|
update_option( "theme_mods_$theme", $mods );
|
||||||
|
|
Loading…
Reference in New Issue