WordPress at a glance
action is not described

after_switch_theme action-hook . WP 3.3.0

Fires on the first WP load after a theme switch if the old theme still exists.

This action fires multiple times and the parameters differs according to the context, if the old theme exists or not. If the old theme is missing, the parameter will be the slug of the old theme.

Usage

add_action( 'after_switch_theme', 'action_function_name_4896', 10, 2 );
function action_function_name_4896( $old_name, $old_theme ){
	// action...
}
$old_name(string)
Old theme name.
$old_theme(WP_Theme)
WP_Theme instance of the old theme.

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

С версии 3.3.0 Введена.

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

check_theme_switched()
after_switch_theme
wp-includes/theme.php 3267
do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme );
wp-includes/theme.php 3270
do_action( 'after_switch_theme', $stylesheet, $old_theme );

Где используется хук в ядре WP

wp-includes/default-filters.php 306
add_action( 'after_switch_theme', '_wp_menus_changed' );
wp-includes/default-filters.php 307
add_action( 'after_switch_theme', '_wp_sidebars_changed' );
wp-includes/theme.php 3248
remove_action( 'after_switch_theme', '_wp_menus_changed' );
wp-includes/theme.php 3249
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );