function js_injector_init in JS injector 6.2
Same name and namespace in other branches
- 6 js_injector.module \js_injector_init()
- 7.2 js_injector.module \js_injector_init()
- 7 js_injector.module \js_injector_init()
Implementation of hook_init(). Checks to see whether any js files should be added to the current page, based on rules configured by the site administrator.
File
- ./
js_injector.module, line 31 - Allows administrators to inject js into the page output based on configurable rules. Useful for adding simple js tweaks without modifying a site's official theme.
Code
function js_injector_init() {
$js_rules = _js_injector_load_rule();
foreach ($js_rules as $js_rule) {
if (_js_injector_evaluate_rule($js_rule)) {
switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
case FILE_DOWNLOADS_PUBLIC:
drupal_add_js(file_create_path(_js_injector_rule_path($js_rule['crid'])), 'module', $js_rule['scope'], FALSE, $js_rule['cache'], $js_rule['preprocess']);
break;
case FILE_DOWNLOADS_PRIVATE:
drupal_add_js("system/files/js_injector_" . $js_rule['crid'] . ".js", 'module', $js_rule['scope'], FALSE, $js_rule['cache'], $js_rule['preprocess']);
break;
}
}
}
}