set_theme_mod()
set_theme_mod( string $name, mixed $value ) 更新当前主题的主题修改…
set_theme_mod( string $name, mixed $value )
更新当前主题的主题修改值。
Update theme modification value for the current theme.
目录锚点:#参数#源码#笔记
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $name | (string) | 主题修改名称。 |
| $value | (mixed) | 主题修改值。 |
源码(Source)
/**
* Update theme modification value for the current theme.
*
* @since 2.1.0
*
* @param string $name Theme modification name.
* @param mixed $value Theme modification value.
*/
function set_theme_mod( $name, $value ) {
$mods = get_theme_mods();
$old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;
/**
* 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' );
update_option( "theme_mods_$theme", $mods );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.1.0 | wp-includes/theme.php | 6 | 5 |
笔记(Notes)
示例用法,挂接到“init”
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!