function modernizr_get_version in Modernizr 7.3
Same name and namespace in other branches
- 8 modernizr.module \modernizr_get_version()
- 7.2 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.
1 call to modernizr_get_version()
- modernizr_requirements in ./
modernizr.install - Implements hook_requirements().
File
- ./
modernizr.module, line 330 - Main module file for Modernizr
Code
function modernizr_get_version($reset = FALSE) {
$version =& drupal_static(__FUNCTION__);
if ($version === NULL || $reset == TRUE) {
if ($cached = cache_get('modernizr_version') && isset($cached->data) && $reset != TRUE) {
$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[0])) {
$version = $matches[0];
if ($version) {
cache_set('modernizr_version', $version);
}
}
unset($modernizr);
}
}
}
return $version;
}