You are here

function advagg_advagg_js_header_footer_alter in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg.module \advagg_advagg_js_header_footer_alter()

Implements hook_advagg_js_header_footer_alter().

File

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

Code

function advagg_advagg_js_header_footer_alter(&$master_set, $preprocess_js, $scheme) {

  // Don't run the code below if ctools ajax is not loaded.
  if (!defined('CTOOLS_AJAX_INCLUDED')) {
    return;
  }

  // Get all JS files set to be loaded.
  $js_files = array();
  foreach ($master_set as $scope => $scripts) {
    if (empty($scripts)) {
      continue;
    }
    advagg_ctools_process_js_files($js_files, $scope, $scripts);
  }

  // Add list of CSS & JS files loaded to the settings in the footer.
  $loaded = array(
    'CToolsAJAX' => array(
      'scripts' => $js_files,
    ),
  );

  // Save to the js settings array even though we do not reload it in advagg.
  drupal_add_js($loaded, array(
    'type' => 'setting',
    'scope' => 'footer',
  ));

  // Add it to the settings array in the footer.
  if (!isset($master_set['footer']['setting']) || !is_array($master_set['footer']['setting'])) {
    $master_set['footer']['setting'] = array();
  }
  $master_set['footer']['setting'][] = $loaded;
}