function hook_advagg_get_js_file_contents_alter in Advanced CSS/JS Aggregation 7.2
Allow other modules to modify this files contents.
Parameters
string $contents: Raw file data.
string $filename: Filename.
array $aggregate_settings: An associative array of hooks and settings used.
See also
advagg_get_css_aggregate_contents()
advagg_css_compress_advagg_get_css_aggregate_contents_alter()
Related topics
3 functions implement hook_advagg_get_js_file_contents_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- advagg_js_compress_advagg_get_js_file_contents_alter in advagg_js_compress/
advagg_js_compress.advagg.inc - Implements hook_advagg_get_js_file_contents_alter().
- advagg_mod_advagg_get_js_file_contents_alter in advagg_mod/
advagg_mod.advagg.inc - Implements hook_advagg_get_js_file_contents_alter().
- advagg_relocate_advagg_get_js_file_contents_alter in advagg_relocate/
advagg_relocate.advagg.inc - Implements hook_advagg_get_js_file_contents_alter().
2 invocations of hook_advagg_get_js_file_contents_alter()
- advagg_get_js_aggregate_contents in ./
advagg.missing.inc - Given a list of files, grab their contents and glue it into one big string.
- advagg_mod_inline_js in advagg_mod/
advagg_mod.module - Transforms all JS files into inline JS.
File
- ./
advagg.api.php, line 276 - Hooks provided by the AdvAgg module.
Code
function hook_advagg_get_js_file_contents_alter(&$contents, $filename, array $aggregate_settings) {
// Do nothing if js file compression is disabled.
if (empty($aggregate_settings['variables']['advagg_js_compressor'])) {
return;
}
// Make sure this file has been tested.
$compressor = $aggregate_settings['variables']['advagg_js_compressor'];
module_load_include('inc', 'advagg', 'advagg');
$info = advagg_get_info_on_file($filename);
if (!isset($info['advagg_js_compress'][$compressor]['code'])) {
// Test file here on the spot.
$info = advagg_js_compress_run_test($filename);
}
// Compress it if it passes the test.
if (!empty($info['advagg_js_compress'][$compressor]['code']) && $info['advagg_js_compress'][$compressor]['code'] == 1) {
advagg_js_compress_prep($contents, $filename, $aggregate_settings);
}
}