You are here

function jquery_update_get_version in jQuery Update 6

Same name and namespace in other branches
  1. 6.2 jquery_update.module \jquery_update_get_version()

Return the version of jQuery that is installed.

This can be used by other modules' hook_requirements() to ensure that the proper version of jQuery is installed.

See also

version_compare

2 calls to jquery_update_get_version()
jquery_update_flush_caches in ./jquery_update.module
Implementation of hook_flush_caches().
jquery_update_requirements in ./jquery_update.install
Implementation of hook_requirements().

File

./jquery_update.module, line 88
Updates Drupal to use the latest version of jQuery.

Code

function jquery_update_get_version($jquery_path = NULL) {
  $version = 0;
  $pattern = '# * jQuery ([0-9\\.a-z]+) - New Wave Javascript#';

  // No file is passed in so default to the file included with this module.
  if (is_null($jquery_path)) {
    $jquery_path = jquery_update_jquery_path();
  }

  // Return the version provided by jQuery Update.
  $jquery = file_get_contents($jquery_path);
  if (preg_match($pattern, $jquery, $matches)) {
    $version = $matches[1];
  }
  return $version;
}