id summary reporter owner description type status priority milestone component version severity resolution keywords cc focuses
10529 API to retrieve current WordPress version stephanreiter "Sometimes it's necessary in plug-ins to check whether a certain functionality or behavior is supported by the current WP version or not. For this purpose I currently use the following code in the Scissors plugin:
{{{
function _minimalWpVersion($major, $minor) {
global $wp_version;
$version = preg_replace(""/[^\\.0-9\s]/"", """", $wp_version); // keep only '0' .. '9' and '.'
$version = explode('.', $version);
return (count($version) >= 2 && ($version[0] > $major || $version[0] == $major && $version[1] >= $minor));
}
}}}
I would love to see the introduction of an API that allows plug-in authors to easily query the current version of WordPress and get a result in the form of an array('major' => 2, 'minor' => 8, 'revision' => 2) (to give an example). This would eliminate potential problems when the format of the version-string changed." enhancement closed normal Plugins minor wontfix close version query