function system_theme_disable

Menu callback; Disables a theme.

1 string reference to 'system_theme_disable'
system_menu in drupal/core/modules/system/system.module
Implements hook_menu().

File

drupal/core/modules/system/system.admin.inc, line 303
Admin page callbacks for the system module.

Code

function system_theme_disable() {
  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
    $theme = $_REQUEST['theme'];

    // Get current list of themes.
    $themes = list_themes();

    // Check if the specified theme is one recognized by the system.
    if (!empty($themes[$theme])) {

      // Do not disable the default or admin theme.
      if ($theme == variable_get('theme_default', 'stark') || $theme == variable_get('admin_theme', 0)) {
        drupal_set_message(t('%theme is the default theme and cannot be disabled.', array(
          '%theme' => $themes[$theme]->info['name'],
        )), 'error');
      }
      else {
        theme_disable(array(
          $theme,
        ));
        drupal_set_message(t('The %theme theme has been disabled.', array(
          '%theme' => $themes[$theme]->info['name'],
        )));
      }
    }
    else {
      drupal_set_message(t('The %theme theme was not found.', array(
        '%theme' => $theme,
      )), 'error');
    }
    drupal_goto('admin/appearance');
  }
  throw new AccessDeniedHttpException();
}