
如何使用Poedit翻译WordPress主题
set_theme_mod ( $name, $value )
set_theme_mod: 这是一个WordPress的函数,设置一个主题的修改。它通常用在主题的 functions.php 文件中,用于定制主题设置,如网站标题或标志: 这个函数需要两个参数:主题修改的名称和要设置的值。
更新活动主题的主题修改值。
function set_theme_mod( $name, $value ) { $mods = get_theme_mods(); $old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false; /** * Filters the theme modification, or '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 mixed $value The new value of the theme modification. * @param mixed $old_value The current value of the theme modification. */ $mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value ); $theme = get_option( 'stylesheet' ); return update_option( "theme_mods_$theme", $mods ); }