You are here

function advagg_process_html in Advanced CSS/JS Aggregation 7

Implements hook_process_html().

1 string reference to 'advagg_process_html'
_advagg_admin_settings_information in includes/admin.inc

File

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

Code

function advagg_process_html(&$variables) {
  global $_advagg, $conf;

  // Invoke hook_advagg_disable_processor
  $disabled = module_invoke_all('advagg_disable_processor');

  // If disabled, skip
  if (!variable_get('advagg_enabled', ADVAGG_ENABLED) || in_array(TRUE, $disabled, TRUE)) {
    if (module_exists('jquery_update')) {
      return jquery_update_preprocess_page($variables);
    }
    else {
      return;
    }
  }

  // Do not use the cache if advagg is set in the URL.
  if (isset($_GET['advagg']) && user_access('bypass advanced aggregation')) {
    $conf['advagg_use_full_cache'] = FALSE;
  }

  // Do not use the cache if the disable cookie is set.
  $cookie_name = 'AdvAggDisabled';
  $key = md5(drupal_get_private_key());
  if (!empty($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name] == $key) {
    $conf['advagg_use_full_cache'] = FALSE;
  }

  // CSS
  advagg_process_html_css($variables);

  // JS
  advagg_process_html_js($variables);

  // Send requests to server if async enabled.
  advagg_async_send_http_request();

  // Write debug info to watchdog if debugging enabled.
  if (variable_get('advagg_debug', ADVAGG_DEBUG)) {
    $data = array(
      'css_before_vars' => $css_orig,
      'css_before_function' => $css_func,
      'css_before_styles' => $css_styles,
      'css_before_inline' => $css_func_inline,
      'css_before_conditional_styles' => $css_conditional_styles,
      'css_merged' => $css,
      'css_after' => $processed_css,
      'js_before' => $js_code_orig,
      'js_after' => $js_code,
    );
    $data['runtime'] = isset($_advagg['debug']) ? $_advagg['debug'] : FALSE;
    $data = str_replace('    ', '    ', nl2br(htmlentities(iconv('utf-8', 'utf-8//IGNORE', print_r($data, TRUE)), ENT_QUOTES, 'UTF-8')));
    watchdog('advagg', 'Debug info: !data', array(
      '!data' => $data,
    ), WATCHDOG_DEBUG);
  }
}