function stickynav_init in Sticky Navigation 6
Same name and namespace in other branches
- 7 stickynav.module \stickynav_init()
Implements hook_init().
File
- ./
stickynav.module, line 11 - Make a menu or some other element on the page stick on top when you scroll down
Code
function stickynav_init() {
global $user, $theme;
$current_theme = $theme;
if (empty($current_theme)) {
$current_theme = variable_get('theme_default', NULL);
}
// Check if user has an exclusion role.
$excluded_roles = array_filter(variable_get('stickynav-roles-' . $current_theme, array()));
if (array_intersect_key($excluded_roles, $user->roles)) {
return;
}
$selector = variable_get('stickynav-selector-' . $current_theme, '');
// Will only add the sticky nav assets if the theme and selector are set.
if (variable_get('stickynav-enabled-' . $current_theme, FALSE) && trim($selector)) {
drupal_add_css(drupal_get_path('module', 'stickynav') . '/css/stickynav.css');
drupal_add_js(drupal_get_path('module', 'stickynav') . '/js/stickynav.js');
$settings = array(
'stickynav' => array(
'selector' => check_plain($selector),
),
);
drupal_add_js($settings, 'setting');
}
}