You are here

function advagg_css_compress_advagg_modify_css_pre_render_alter in Advanced CSS/JS Aggregation 7.2

Implements hook_advagg_modify_css_pre_render_alter().

Used to compress inline css.

Related topics

File

advagg_css_compress/advagg_css_compress.module, line 86
Advanced aggregation css compression module.

Code

function advagg_css_compress_advagg_modify_css_pre_render_alter(&$children, &$elements) {

  // Get variables.
  $compressor = variable_get('advagg_css_compress_inline', ADVAGG_CSS_COMPRESS_INLINE);

  // Do nothing if the compressor is disabled.
  if (empty($compressor)) {
    return;
  }

  // Do nothing if the page is not cacheable and inline compress if not
  // cacheable is not checked.
  if (!variable_get('advagg_css_compress_inline_if_not_cacheable', ADVAGG_CSS_COMPRESS_INLINE_IF_NOT_CACHEABLE) && !drupal_page_is_cacheable()) {
    return;
  }
  module_load_include('inc', 'advagg_css_compress', 'advagg_css_compress.advagg');
  if ($compressor == 2) {

    // Compress any inline CSS with YUI.
    foreach ($children as &$values) {
      if (!empty($values['#value'])) {
        advagg_css_compress_yui_cssmin($values['#value']);
      }
    }
    unset($values);
  }
}