Different jQuery version on admin pages and hook_requirements()

Created on 8 December 2015, almost 9 years ago
Updated 2 May 2024, 7 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.

  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    I'm closing it because the issue was created a long time ago without any further steps.

    if you still need it then raise a new one.
    thanks

Production build 0.71.5 2024