function deactivate_theme($blog_id) { global $psts; $current_theme = get_blog_option($blog_id, 'stylesheet'); $psts_allowed_themes = $psts->get_setting('pt_allowed_themes'); $blog_allowed_themes = get_blog_option($blog_id, 'psts_blog_allowed_themes'); $is_pro_site = is_pro_site($blog_id); // Makes sure its not a Pro Site and then remove the Pro Sites themes if (!$is_pro_site) { foreach ($psts_allowed_themes as $key => $value) { if (isset($blog_allowed_themes[$key])) { unset($blog_allowed_themes[$key]); } } update_blog_option($blog_id, 'psts_blog_allowed_themes', $blog_allowed_themes); } //if not using pro theme skip if (!isset($psts_allowed_themes[$current_theme])) { return; } //if they have permission for this theme skip if (is_pro_site($blog_id, $psts_allowed_themes[$current_theme]) || $this->ads_theme()) { return; } //check for our default theme plugin first if (function_exists('default_theme_switch_theme')) { default_theme_switch_theme($blog_id); } else { switch_to_blog($blog_id); if (defined(WP_DEFAULT_THEME) && !empty($blog_allowed_themes[WP_DEFAULT_THEME])) { switch_theme(WP_DEFAULT_THEME, WP_DEFAULT_THEME); } else { // switch to first available theme if default is not set or not allowed $theme = key($blog_allowed_themes); switch_theme($theme, $theme); } restore_current_blog(); } }
function deactivate_theme($blog_id) { global $psts; $current_theme = get_blog_option($blog_id, 'stylesheet'); $psts_allowed_themes = $psts->get_setting('pt_allowed_themes'); //if not using pro theme skip if (!isset($psts_allowed_themes[$current_theme])) { return; } //if they have permission for this theme skip if (is_pro_site($blog_id, $psts_allowed_themes[$current_theme]) || $this->ads_theme()) { return; } //check for our default theme plugin first if (function_exists('default_theme_switch_theme')) { default_theme_switch_theme($blog_id); } else { switch_to_blog($blog_id); switch_theme(WP_DEFAULT_THEME, WP_DEFAULT_THEME); restore_current_blog(); } }