You are here

function advagg_relocate_advagg_get_info_on_files_alter in Advanced CSS/JS Aggregation 7.2

Implements hook_advagg_get_info_on_files_alter().

Related topics

File

advagg_relocate/advagg_relocate.advagg.inc, line 16
Advanced aggregation relocate module.

Code

function advagg_relocate_advagg_get_info_on_files_alter(&$return, $cached_data, $bypass_cache) {
  $aggregate_settings = advagg_current_hooks_hash_array();

  // Check external js setting.
  if (empty($aggregate_settings['variables']['advagg_relocate_js'])) {
    return;
  }
  foreach ($return as $key => &$info) {

    // Skip if not a js file.
    if (empty($info['fileext']) || $info['fileext'] !== 'js') {
      continue;
    }

    // Get the file contents.
    $file_contents = (string) @advagg_file_get_contents($info['data']);
    if (empty($file_contents)) {
      continue;
    }
    $value['data'] = $file_contents;
    $scripts_found = advagg_relocate_js_script_rewrite_list($key, $value, $aggregate_settings);
    if (!empty($scripts_found)) {
      $info['advagg_relocate'] = $scripts_found;
    }
  }
}