Wordpress - Is there a hook for when you switch themes?
There is a 'switch_theme' action that runs right after the theme is switched.
function my_on_switch_theme($new_theme) {
$current_themes = wp_get_themes(); /* Fixed deprecated function */
$new_theme_info = $current_themes[$new_theme];
/*
$new_theme_info should now be an associative array with the following:
$new_theme_info['Title'];
$new_theme_info['Version'];
$new_theme_info['Parent Theme'];
$new_theme_info['Template Dir'];
$new_theme_info['Stylesheet Dir'];
$new_theme_info['Template'];
$new_theme_info['Stylesheet'];
$new_theme_info['Screenshot'];
$new_theme_info['Description'];
$new_theme_info['Author'];
$new_theme_info['Tags'];
$new_theme_info['Theme Root'];
$new_theme_info['Theme Root URI'];
...so do what you need from this.
*/
}
add_action('switch_theme', 'my_on_switch_theme');
In WordPress 1.5 and greater the action you're looking for is called switch theme.
You can see it in source in theme.php.