Different jQuery version on admin pages and hook_requirements()

Created on 8 December 2015, over 8 years ago
Updated 2 May 2024, about 2 months ago

Nice menus has a jQuery version requirement: >='1.8'

...but sometimes we need different jQuery version ( e.g. provided by Drupal core: 1.4 ) on admin pages. This causes that update.php can not run, because this path is admin path and jQuery version is less than 1.8. But usually we don't need nice menus on admin pages. My quick fix is a modified nice_menus_requirements(), but it's not the perfect solution:

/**
 * Implements hook_requirements().
 */
function nice_menus_requirements($phase) {
  $requirements = array();
  if ($phase != 'update') {
    $jquery = drupal_get_library('system', 'jquery');
    if (version_compare($jquery['version'], '1.8', '<')) {
      $requirements['nice_menus'] = array(
        'title' => t('Nice menus'),
        'value' => 'jQuery >=1.8',
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
}
  return $requirements;
}
✨ Feature request
Status

Closed: outdated

Version

3.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary fox mulder

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024