You are here

function admin_menu_init in Administration menu 6

Same name and namespace in other branches
  1. 6.3 admin_menu.module \admin_menu_init()
  2. 7.3 admin_menu.module \admin_menu_init()

Implementation of hook_init().

We can't move this into admin_menu_footer(), because PHP-only based themes like chameleon load and output scripts and stylesheets in front of theme_closure(), so we ensure Admin menu's styles and scripts are loaded on all pages via hook_init().

File

./admin_menu.module, line 80
Renders a menu tree for administrative purposes as a dropdown menu at the top of the window.

Code

function admin_menu_init() {
  if (user_access('access administration menu')) {
    $path = drupal_get_path('module', 'admin_menu');
    drupal_add_css($path . '/admin_menu.css', 'module', 'all', FALSE);

    // Performance: Defer execution.
    drupal_add_js($path . '/admin_menu.js', 'module', 'header', TRUE);
    if ($setting = variable_get('admin_menu_margin_top', 1)) {
      drupal_add_js(array(
        'admin_menu' => array(
          'margin_top' => $setting,
        ),
      ), 'setting');
    }
    if ($setting = variable_get('admin_menu_position_fixed', 0)) {
      drupal_add_js(array(
        'admin_menu' => array(
          'position_fixed' => $setting,
        ),
      ), 'setting');
    }
    if ($setting = variable_get('admin_menu_tweak_tabs', 0)) {
      drupal_add_js(array(
        'admin_menu' => array(
          'tweak_tabs' => $setting,
        ),
      ), 'setting');
    }
    if ($_GET['q'] == 'admin/build/modules' || strpos($_GET['q'], 'admin/build/modules/list') === 0) {
      drupal_add_js(array(
        'admin_menu' => array(
          'tweak_modules' => variable_get('admin_menu_tweak_modules', 0),
        ),
      ), 'setting');
    }
  }
}