I've got some code inside functions.php which is designed to execute only when the theme is first activated:
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
//this code only runs when the theme is first activated
}
However, I'm pretty sure this code is not running if the theme is activated outside the normal activation process. For example, if a switch_theme() statement is called from a plugin.
In that case, how might I alter my code above to execute on switch_theme()?
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php') OR (switch_theme_called() ) ) {
//this code only runs when the theme is first activated
}