[wp-hackers] How to determine which WordPress version is running ?

Mark Jaquith mark.wordpress at txfx.net
Tue Jan 23 07:21:06 GMT 2007


On Jan 23, 2007, at 1:14 AM, Viper007Bond wrote:

> Okay, my revised suggestion:
>
> global $wp_version;
> if ( version_compare($wp_version, '2.1') == -1 ) die('Your version  
> is too
> low!');

I personally like to pass the third (optional) comparison param to  
version_compare().  When you do this, version_compare() returns true/ 
false (instead of the confusing -1, 0, 1).  No benefit other than  
readability.

<?php
global $wp_version;
if ( version_compare($wp_version, '2.1', '<') )
	die('Your version is too low!');
?>

Note that the direction of the comparison param is just as if it were  
moved to the left, inbetween the first and second param.

--
Mark Jaquith
http://markjaquith.com/

Covered Web Services
http://covered.be/




More information about the wp-hackers mailing list