Filter hook 'pre_set_theme_mod_{$name}'

in WP Core File wp-includes/theme.php at line 1111

View Source

pre_set_theme_mod_{$name}

Filter Hook
Description
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.

Hook Information

File Location wp-includes/theme.php View on GitHub
Hook Type Filter
Line Number 1111

Hook Parameters

Type Name Description
mixed $value The new value of the theme modification.
mixed $old_value The current value of the theme modification.

Usage Examples

Basic Usage
<?php
// Hook into pre_set_theme_mod_{$name}
add_filter('pre_set_theme_mod_{$name}', 'my_custom_filter', 10, 2);

function my_custom_filter($value, $old_value) {
    // Your custom filtering logic here
    return $value;
}

Source Code Context

wp-includes/theme.php:1111 - How this hook is used in WordPress core
<?php
1106  	 * @since 3.9.0
1107  	 *
1108  	 * @param mixed $value     The new value of the theme modification.
1109  	 * @param mixed $old_value The current value of the theme modification.
1110  	 */
1111  	$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
1112  
1113  	$theme = get_option( 'stylesheet' );
1114  
1115  	return update_option( "theme_mods_$theme", $mods );
1116  }

PHP Documentation

<?php
/**
	 * 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/theme.php
Related Hooks

Related hooks will be displayed here in future updates.