Only allow the feature if admin is logged in.

Currently it's loading the admin_menu_dropdown.css and admin_menu_dropdown.js when anon users are browsing; total waste.

Change admin_menu_dropdown.module:

  drupal_add_js($path . '/admin_menu_dropdown.js', 'module', 'header', TRUE, TRUE, FALSE);
  drupal_add_js(array('admin_menu_dropdown' => $settings), 'setting');
  drupal_add_css($path . '/admin_menu_dropdown.css', 'theme', 'all', FALSE);

To this:

if(user_access('administer')) {
  drupal_add_js($path . '/admin_menu_dropdown.js', 'module', 'header', TRUE, TRUE, FALSE);
  drupal_add_js(array('admin_menu_dropdown' => $settings), 'setting');
  drupal_add_css($path . '/admin_menu_dropdown.css', 'theme', 'all', FALSE);
}

Comments

Josephnewyork’s picture

It should be the permission to match the admin_menu's permissions as this is just an add-on to admin_menu. It should be:

/**
 * Implements hook_init().
 */
function admin_menu_dropdown_init() {
  if(!user_access('access administration menu')) return;
  ...
}

This is the same for Drupal 6 and 7 modules.