function _color_html_alter

_color_html_alter(&$vars)

Replaces style sheets with color-altered style sheets.

A theme that supports the color module should call this function from its THEME_process_html() function, so that the correct style sheets are included when html.tpl.php is rendered.

See also

theme()

File

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

Code

function _color_html_alter(&$vars) {
  global $theme_key;
  $themes = list_themes();

  // Override stylesheets.
  $color_paths = variable_get('color_' . $theme_key . '_stylesheets', array());
  if (!empty($color_paths)) {

    foreach ($themes[$theme_key]->stylesheets['all'] as $base_filename => $old_path) {
      // Loop over the path array with recolored CSS files to find matching
      // paths which could replace the non-recolored paths.
      foreach ($color_paths as $color_path) {
        // Color module currently requires unique file names to be used,
        // which allows us to compare different file paths.
        if (drupal_basename($old_path) == drupal_basename($color_path)) {
          // Replace the path to the new css file.
          // This keeps the order of the stylesheets intact.
          $vars['css'][$old_path]['data'] = $color_path;
        }
      }
    }

    $vars['styles'] = drupal_get_css($vars['css']);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!color!color.module/function/_color_html_alter/7.x