option_(option) filter-hookWP 3.0.0

Filters the value of an existing option.

The dynamic portion of the hook name, $option, refers to the option name.

Usage

add_filter( 'option_(option)', 'wp_kama_option_filter', 10, 2 );

/**
 * Function for `option_(option)` filter-hook.
 * 
 * @param mixed  $value  Value of the option. If stored serialized, it will be unserialized prior to being returned.
 * @param string $option Option name.
 *
 * @return mixed
 */
function wp_kama_option_filter( $value, $option ){

	// filter...
	return $value;
}
$value(mixed)
Value of the option. If stored serialized, it will be unserialized prior to being returned.
$option(string)
Option name.

Changelog

Since 3.0.0 Introduced.
Since 1.5.0 As 'option_' . $setting
Since 4.4.0 The $option parameter was added.

Where the hook is called

get_option()
option_(option)
WP_Customize_Widgets::capture_filter_pre_get_option()
option_(option)
wp-includes/option.php 247
return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
wp-includes/class-wp-customize-widgets.php 2156
$value = apply_filters( 'option_' . $option_name, $value, $option_name );

Where the hook is used in WordPress

wp-includes/class-wp-customize-setting.php 383
add_filter( "option_{$id_base}", $multidimensional_filter );
wp-includes/class-wp-customize-widgets.php 282
add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 );
wp-includes/customize/class-wp-customize-nav-menu-setting.php 224
add_filter( 'option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) );
wp-includes/default-filters.php 290
add_filter( 'option_ping_sites', 'privacy_ping_filter' );
wp-includes/default-filters.php 291
add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop.
wp-includes/default-filters.php 292
add_filter( 'option_blog_charset', '_canonical_charset' );
wp-includes/default-filters.php 293
add_filter( 'option_home', '_config_wp_home' );
wp-includes/default-filters.php 294
add_filter( 'option_siteurl', '_config_wp_siteurl' );
wp-includes/default-filters.php 304
add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' );
wp-includes/default-filters.php 305
add_filter( 'option_category_base', '_wp_filter_taxonomy_base' );
wp-includes/ms-default-filters.php 120
remove_filter( 'option_siteurl', '_config_wp_siteurl' );
wp-includes/ms-default-filters.php 121
remove_filter( 'option_home', '_config_wp_home' );
wp-includes/ms-default-filters.php 20
add_filter( 'option_users_can_register', 'users_can_register_signup_filter' );