1.20.x color.module color_rebuild_settings($theme_name = NULL)

Rebuild color scheme info.

File

modules/color/color.module, line 543
Allows users to change the color scheme of themes.

Code

function color_rebuild_settings($theme_name = NULL) {
  $themes = array();
  if ($theme_name) {
    $themes = array($theme_name);
  }
  else {
    foreach (list_themes() as $key => $data) {
      if ($data->status) {
        $themes[] = $key;
      }
    }
  }

  foreach ($themes as $theme) {
    $theme_config_name = $theme . '.settings';
    $theme_config = config($theme_config_name);
    if ($theme_config && $new_color_config = $theme_config->get('color')) {
      $color_info = color_get_info($theme);
      if ($color_info) {
        $palette = isset($new_color_config['palette']) ? $new_color_config['palette'] : NULL;
        $new_color_info = color_save_configuration($theme, $color_info, $palette);
        $theme_config->set('color', $new_color_info);
        $theme_config->save();
      }
    }
  }
}