function restrict_ip_js_alter in Restrict IP 7.2
Same name and namespace in other branches
- 8.2 restrict_ip.module \restrict_ip_js_alter()
- 8 restrict_ip.module \restrict_ip_js_alter()
- 7 restrict_ip.module \restrict_ip_js_alter()
- 3.x restrict_ip.module \restrict_ip_js_alter()
Implements hook_js_alter().
This function removes all javascript from the page with the exception of jquery.js and the javascript file provided with the module.
File
- ./
restrict_ip.module, line 416 - Holds hooks for the restrict_ip module.
Code
function restrict_ip_js_alter(&$javascript) {
if (ip_restricted()) {
$whitelisted_keys = array(
'misc/jquery.js',
drupal_get_path('module', 'restrict_ip') . '/js/restrict_ip.js',
);
foreach (module_implements('restrict_ip_whitelisted_js_keys') as $module_name) {
$function = $module_name . '_restrict_ip_whitelisted_js_keys';
$whitelisted_keys = array_merge($whitelisted_keys, $function());
}
foreach (array_keys($javascript) as $key) {
if (!in_array($key, $whitelisted_keys)) {
unset($javascript[$key]);
}
}
}
}