switch_theme
Fires after the theme is switched.
See after_switch_theme.
Usage
add_action( 'switch_theme', 'wp_kama_switch_theme_action', 10, 3 ); /** * Function for `switch_theme` action-hook. * * @param string $new_name Name of the new theme. * @param WP_Theme $new_theme WP_Theme instance of the new theme. * @param WP_Theme $old_theme WP_Theme instance of the old theme. * * @return void */ function wp_kama_switch_theme_action( $new_name, $new_theme, $old_theme ){ // action... }
- $new_name(string)
- Name of the new theme.
- $new_theme(WP_Theme)
- WP_Theme instance of the new theme.
- $old_theme(WP_Theme)
- WP_Theme instance of the old theme.
Changelog
Since 1.5.0 | Introduced. |
Since 4.5.0 | Introduced the $old_theme parameter. |
Where the hook is called
switch_theme
wp-includes/theme.php 878
do_action( 'switch_theme', $new_name, $new_theme, $old_theme );
Where the hook is used in WordPress
wp-includes/default-filters.php 368
add_action( 'switch_theme', 'wp_clean_theme_json_cache' );