1 theme.inc theme_enable($theme_list)

Enables a given list of themes.

Parameters

$theme_list: An array of theme names.

File

core/includes/theme.inc, line 1662
The theme system, which controls the output of Backdrop.

Code

function theme_enable($theme_list) {
  backdrop_clear_css_cache();

  foreach ($theme_list as $theme) {
    db_update('system')
      ->fields(array('status' => 1))
      ->condition('type', 'theme')
      ->condition('name', $theme)
      ->execute();

    // Copy any default configuration data to the system config directory.
    config_install_default_config($theme);

    // Update the theme status in the system.extensions config.
    $config = config('system.extensions');
    $themes_in_config = $config->get('themes') != NULL ? $config->get('themes') : array();
    $themes_in_config[$theme] = TRUE;

    watchdog('system', '%theme theme enabled.', array('%theme' => $theme), WATCHDOG_INFO);
  }

  // Save the updated config.
  if (isset($config) && isset($themes_in_config)) {
    $config->set('themes', $themes_in_config);
    $config->save();
  }

  list_themes(TRUE);
  menu_rebuild();
  backdrop_theme_rebuild();

  // Invoke hook_themes_enabled() after the themes have been enabled.
  module_invoke_all('themes_enabled', $theme_list);
}