function advagg_mod_process_move_js in Advanced CSS/JS Aggregation 7.2
Implements hook_process().
Used to wrap inline JS in a function in order to prevent js errors when JS is moved to the footer.
1 string reference to 'advagg_mod_process_move_js'
- advagg_mod_theme_registry_alter in advagg_mod/
advagg_mod.module - Implements hook_theme_registry_alter().
File
- advagg_mod/
advagg_mod.module, line 546 - Advanced aggregation modifier module.
Code
function advagg_mod_process_move_js(array &$variables) {
if (!module_exists('advagg') || !advagg_enabled()) {
return;
}
// Return if settings are disabled.
if (!variable_get('advagg_mod_js_footer_inline_alter', ADVAGG_MOD_JS_FOOTER_INLINE_ALTER) && !variable_get('advagg_mod_js_inline_resource_hints', ADVAGG_MOD_JS_INLINE_RESOURCE_HINTS)) {
return;
}
// Search all the children for script tags.
foreach (element_children($variables) as $child) {
// Skip if empty.
if (empty($variables[$child])) {
continue;
}
// Handle strings.
if (is_string($variables[$child]) && stripos($variables[$child], '<script') !== FALSE) {
advagg_mod_js_inline_processor($variables[$child]);
}
if (is_array($variables[$child])) {
if (isset($variables[$child]['#children']) && is_string($variables[$child]['#children']) && stripos($variables[$child]['#children'], '<script') !== FALSE) {
advagg_mod_js_inline_processor($variables[$child]['#children']);
}
if (isset($variables[$child]['#markup']) && is_string($variables[$child]['#markup']) && stripos($variables[$child]['#markup'], '<script') !== FALSE) {
// advagg_mod_js_inline_processor($variables[$child]['#markup']);
// Uncomment to also process #markup.
}
// advagg_mod_process_move_js($variables[$child]);
// Uncomment to make this recursive.
}
}
}