function advagg_mod_inline_css

nittany7 advagg_mod.module advagg_mod_inline_css(&$css)
cis7 advagg_mod.module advagg_mod_inline_css(&$css)
mooc7 advagg_mod.module advagg_mod_inline_css(&$css)

Transforms all CSS files into inline CSS.

Parameters

$css: CSS array.

See also

advagg_get_css_aggregate_contents()

drupal_build_css_cache()

1 call to advagg_mod_inline_css()
advagg_mod_css_alter in modules/contrib/advagg/advagg_mod/advagg_mod.module
Implements hook_css_alter().

File

modules/contrib/advagg/advagg_mod/advagg_mod.module, line 333
Advanced aggregation modifier module.

Code

function advagg_mod_inline_css(&$css) {
  $aggregate_settings = advagg_current_hooks_hash_array();
  $optimize = TRUE;
  module_load_include('inc', 'advagg', 'advagg');

  foreach ($css as $name => &$values) {
    // Only process files.
    if ($values['type'] != 'file') {
      continue;
    }

    $file = $values['data'];
    if (file_exists($file)) {
      $contents = advagg_load_css_stylesheet($file, $optimize, $aggregate_settings);

      // Allow other modules to modify this files contents.
      // Call hook_advagg_get_css_file_contents_alter().
      drupal_alter('advagg_get_css_file_contents', $contents, $file, $aggregate_settings);

      // Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
      // @import rules must proceed any other style, so we move those to the top.
      $regexp = '/@import[^;]+;/i';
      preg_match_all($regexp, $contents, $matches);
      $contents = preg_replace($regexp, '', $contents);
      $contents = implode('', $matches[0]) . $contents;

      $values['data'] = $contents;
      $values['type'] = 'inline';
    }
  }
}