function optimizely_init in Optimizely 6
Same name and namespace in other branches
- 7.3 optimizely.module \optimizely_init()
- 7 optimizely.module \optimizely_init()
- 7.2 optimizely.module \optimizely_init()
Implements hook_init().
File
- ./
optimizely.module, line 28 - Optimizely module
Code
function optimizely_init() {
// Grab the ID, but only proceed if it's set to something.
$optimizely_id = variable_get('optimizely_id', 'NONE');
$optimizely_onoff = variable_get('optimizely_onoff', 'on');
if ($optimizely_onoff == 'on' && $optimizely_id != "NONE") {
$protocol = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
$optimizely_script = $protocol . ':' . '//cdn.optimizely.com/js/' . $optimizely_id . '.js';
drupal_set_html_head('<script type="text/javascript" src="' . $optimizely_script . '"></script>');
}
}