You are here

function advagg_color_css in Advanced CSS/JS Aggregation 6

Remove css files from the array if there is a color module equivalent of it.

Parameters

$css_func: Drupal CSS array.

1 call to advagg_color_css()
advagg_processor in ./advagg.module
Process variables for page.tpl.php

File

./advagg.module, line 552
Advanced CSS/JS aggregation module

Code

function advagg_color_css(&$css) {
  if (!module_exists('color') || empty($css['all']['theme'])) {
    return;
  }
  $file_path = file_directory_path();

  // Find all color css files.
  $files = array();
  foreach ($css['all']['theme'] as $file => $preprocess) {
    if (strpos($file, $file_path) === FALSE) {
      continue;
    }
    if (strpos($file, '/color/') === FALSE) {
      continue;
    }
    $files[basename($file)] = $file;
  }

  // Return if no color css files are found.
  if (empty($files)) {
    return;
  }

  // Remove css files from the stack if there is a color variant of it.
  foreach ($css['all']['theme'] as $file => $preprocess) {
    $basename = basename($file);
    if (isset($files[$basename]) && !in_array($file, $files)) {
      unset($css['all']['theme'][$file]);
    }
  }
}