option_(option) хук-фильтрWP 3.0.0

Filters the value of an existing option.

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

Использование

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(разное)
Value of the option. If stored serialized, it will be unserialized prior to being returned.
$option(строка)
Option name.

Список изменений

С версии 3.0.0 Введена.
С версии 1.5.0 As 'option_' . $setting
С версии 4.4.0 The $option parameter was added.

Где вызывается хук

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 );

Где используется хук в 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 289
add_filter( 'option_ping_sites', 'privacy_ping_filter' );
wp-includes/default-filters.php 290
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 291
add_filter( 'option_blog_charset', '_canonical_charset' );
wp-includes/default-filters.php 292
add_filter( 'option_home', '_config_wp_home' );
wp-includes/default-filters.php 293
add_filter( 'option_siteurl', '_config_wp_siteurl' );
wp-includes/default-filters.php 303
add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' );
wp-includes/default-filters.php 304
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' );