You are here

function advagg_mod_inline_js in Advanced CSS/JS Aggregation 7.2

Transforms all JS files into inline JS.

Parameters

array $js: JS array.

1 call to advagg_mod_inline_js()
_advagg_mod_pre_render_scripts in advagg_mod/advagg_mod.module
Callback for pre_render to inline all JavaScript on this page.

File

advagg_mod/advagg_mod.module, line 3273
Advanced aggregation modifier module.

Code

function advagg_mod_inline_js(array &$js) {
  $aggregate_settings = advagg_current_hooks_hash_array();
  foreach ($js as &$values) {

    // Only process files.
    if ($values['type'] !== 'file') {
      continue;
    }
    $filename = $values['data'];
    if (file_exists($filename)) {
      $contents = (string) @advagg_file_get_contents($filename);
    }

    // Allow other modules to modify this files contents.
    // Call hook_advagg_get_js_file_contents_alter().
    drupal_alter('advagg_get_js_file_contents', $contents, $filename, $aggregate_settings);
    $values['data'] = $contents;
    $values['type'] = 'inline';
  }
  unset($values);
}