You are here

function magic_css_js_alter in Magic 7

Same name and namespace in other branches
  1. 7.2 magic.module \magic_css_js_alter()

Helper function to remove unwanted css or js.

Parameters

array $data: The css or js array.

string $type (default: 'css'): Either 'css' or 'js' depending on the file array.

2 calls to magic_css_js_alter()
magic_css_alter in ./magic.module
Implements hook_css_alter().
magic_js_alter in ./magic.module
Implements hook_js_alter().

File

./magic.module, line 578
Keep Frontend DRY; sprinkle it with MAGIC!

Code

function magic_css_js_alter(&$data, $type = 'css') {
  global $theme_key;

  // First check to see if we are even going to exclude anything.
  $excludes = theme_get_setting("magic_{$type}_excludes_regex");
  if (is_array($excludes)) {

    // We get the hash of the css array to check if it has been passed already.
    $cid = $theme_key . "_{$type}_" . hash('md4', serialize($data));
    $cache = _magic_check_cache($cid);
    if ($cache) {

      // We have this array cached, use it.
      $data = $cache;
    }
    else {
      module_load_include('inc', 'magic', 'includes/magic');
      magic_exclude_assets($data, $excludes['exclude'], $excludes['include']);
      _magic_set_cache($cid, $data);
    }
  }
}