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[] = $exit_msg; } }
Back in your loader.php
, you would reference this test by name and pass it a minimum required version of WordPress:
// Run Tests. MyPlugin_tests::wp_version_gt('3.0.1');
You...