O'Reilly logo

WordPress 3 Plugin Development Essentials by Everett Griffiths, Brian Bondari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing WordPress version

We demonstrated this in our chapter about Social Networking, but here it is again, this time adapted for use in a testing class. You can add this to your plugin's dedicated testing class and reference it by name in your loader.php file:

/** * Tests that the current version of WP is greater than $ver. * * @param string $ver the version of WordPress your plugin requires in order to work, e.g. '3.0.1' * @return none Registers an error in the self::$errors array. */ public static function wp_version_gt($ver) { global $wp_version; $exit_msg = __("MyPlugin requires WordPress $ver or newer. <a href='http://codex.wordpress.org/Upgrading_WordPress'>Please update!</a>"); if (version_compare($wp_version,$ver,'<')) { self::$errors[] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required