функция
since 2.1.0
set_theme_mod()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
set_theme_mod( string $name, mixed $value ): bool
Описание
Обновляет значение модификации темы для активной темы.
Параметры
$name
string
обязательный
Имя модификации темы.
$value
mixed
обязательный
Значение модификации темы.
Возвращаемое значение
bool
Исходный код
wp-includes/theme.php:1105
function set_theme_mod( $name, $value ) {
$mods = get_theme_mods();
$old_value = $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 );
}
История изменений
| Версия | Описание |
|---|---|
| 5.6.0 | A return value was added. |
| 2.1.0 | Introduced. |

