Implements hook_init().
Fichier
-
advagg_mod/
advagg_mod.module, line 289
Code
function advagg_mod_init() {
if (!module_exists('advagg') || !advagg_enabled()) {
return;
}
// Adjust devel_shutdown callback.
if (variable_get('advagg_enabled', ADVAGG_ENABLED) && (variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER) || variable_get('advagg_mod_js_async', ADVAGG_MOD_JS_ASYNC))) {
$callbacks =& drupal_register_shutdown_function();
foreach ($callbacks as $key => $values) {
if ($values['callback'] === 'devel_shutdown') {
$callbacks[$key]['callback'] = 'advagg_mod_devel_shutdown';
break;
}
}
reset($callbacks);
}
// Return if unified_multisite_dir is not set.
$dir = rtrim(variable_get('advagg_mod_unified_multisite_dir', ''), '/');
if (!empty($dir) && file_exists($dir) && is_dir($dir)) {
$counter_filename = $dir . '/' . ADVAGG_SPACE . 'advagg_global_counter';
$local_counter = advagg_get_global_counter();
if (!file_exists($counter_filename)) {
module_load_include('inc', 'advagg', 'advagg.missing');
advagg_save_data($counter_filename, $local_counter);
}
else {
$shared_counter = (int) advagg_file_get_contents($counter_filename);
if ($shared_counter == $local_counter) {
// Counters are the same, return.
}
elseif ($shared_counter < $local_counter) {
// Local counter is higher, update saved file and return.
module_load_include('inc', 'advagg', 'advagg.missing');
advagg_save_data($counter_filename, $local_counter, TRUE);
}
elseif ($shared_counter > $local_counter) {
// Shared counter is higher, update local copy and return.
variable_set('advagg_global_counter', $shared_counter);
}
}
}
// Disable js in footer on imce page.
// Disable js defer on imce page.
// https://www.drupal.org/node/2817523
if (module_exists('imce')) {
$args = arg();
if ($args[0] === 'imce' && empty($args[1])) {
if (variable_get('advagg_mod_js_footer', ADVAGG_MOD_JS_FOOTER)) {
$GLOBALS['conf']['advagg_mod_js_footer'] = 0;
}
if (variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER)) {
$GLOBALS['conf']['advagg_mod_js_defer'] = 0;
}
}
}
}