WordPress at a glance

set_theme_mod() WP 1.0

Update theme modification value for the current theme.

✈ 1 time = 0.000983s = slow | 50000 times = 4.90s = fast
Hooks from function:
Return

Nothing (null).

Usage

set_theme_mod( $name, $value );
$name(string) (required)
Theme modification name.
$value(mixed) (required)
Theme modification value.

Code of set_theme_mod: wp-includes/theme.php VER 4.9.8

<?php
function set_theme_mod( $name, $value ) {
	$mods = get_theme_mods();
	$old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;

	/**
	 * Filters 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 );
}

Related Functions

From tag: Theme Modification API (theme mods options settings)

More from category: Other Theme Functions

No comments
    Hello, !     Log In . Register