You are here

function modernizr_get_version in Modernizr 7.2

Same name and namespace in other branches
  1. 8 modernizr.module \modernizr_get_version()
  2. 7.3 modernizr.module \modernizr_get_version()

Guesses the modernizr library version.

This function is using a regex, which assumes that the format of the version string won't change. If it changes, feel free to submit a bug report.

Return value

mixed The version number if exists, or a boolean FALSE if it can't be determined.

2 calls to modernizr_get_version()
modernizr_init in ./modernizr.module
Implements hook_init().
modernizr_requirements in ./modernizr.install
Implements hook_requirements.

File

./modernizr.module, line 149

Code

function modernizr_get_version() {
  $version =& drupal_static(__FUNCTION__);
  if ($version === NULL) {
    if ($cached = cache_get('modernizr_version')) {
      $version = $cached->data;
    }
    else {
      $version = FALSE;
      $modernizr_path = modernizr_get_path();
      if (file_exists($modernizr_path)) {
        $modernizr = file_get_contents($modernizr_path);
        $matches = array();
        preg_match(MODERNIZR_VERSION_REGEX, $modernizr, $matches);
        if (isset($matches[1])) {
          $version = $matches[1];
          if ($version) {
            cache_set('modernizr_version', $version);
          }
        }
        unset($modernizr);
      }
    }
  }
  return $version;
}