Disable a given list of themes.
$theme_list: An array of theme names.
function theme_disable($theme_list) {
// Don't disable the default theme.
if ($pos = array_search(variable_get('theme_default', 'stark'), $theme_list) !== FALSE) {
unset($theme_list[$pos]);
if (empty($theme_list)) {
return;
}
}
drupal_clear_css_cache();
$theme_config = config('system.theme');
$disabled_themes = config('system.theme.disabled');
foreach ($theme_list as $key) {
// The value is not used; the weight is ignored for themes currently.
$theme_config
->clear("enabled.{$key}");
$disabled_themes
->set($key, 0);
}
$theme_config
->save();
$disabled_themes
->save();
list_themes(TRUE);
menu_router_rebuild();
drupal_theme_rebuild();
// Invoke hook_themes_disabled after the themes have been disabled.
module_invoke_all('themes_disabled', $theme_list);
}