So, if a plugin should not ever be installed on an older version of WordPress, whats the best way to go about it? What I normally do is something like this:
if ( ! function_exists( 'get_post_format' ) ) {
$error_handler = set_error_handler( 'my_plugin_die' );
trigger_error( '', E_USER_ERROR );
}
function my_plugin_die( $errno, $errstr, $errfile, $errline ) {
global $wp_version;
exit( 'This plugin requires WordPress version 3.0 or greater. You are currently using version ' . $wp_version . '. Please <a target="_top" href="' . esc_url( admin_url( 'update-core.php' ) ) . '">upgrade to the latest version of WordPress</a> before installing this plugin.' );
}
I place this straight in the plugin file - outside of any class. It seems to work well in all of my testing, but seems rather harsh. Is there any chance of a plugin having this code will ever be activated?
How to you deal with situations like this? There seems to be absolutely no documentation on this kind of thing.