[wp-hackers] How do I prevent activation of plugin is below PHP 5?

Otto otto at ottodestruct.com
Fri Jul 9 07:03:20 UTC 2010


/**
 * plugin_activation_check()
 *
 * Replace "plugin" with the name of your plugin
 */
function plugin_activation_check(){
	if (version_compare(PHP_VERSION, '5.0.0', '<')) {
		deactivate_plugins(basename(__FILE__)); // Deactivate ourself
		wp_die("Sorry, but you can't run this plugin, it requires PHP 5 or higher.");
	}
}
register_activation_hook(__FILE__, 'plugin_activation_check');


-Otto



On Fri, Jul 9, 2010 at 12:41 AM, Raj <list at expost.org> wrote:
> Hi all,
>
>
>
> I am getting a lot of emails from users of my plugin who are running it on
> PHP 4.x and are seeing errors. How do I prevent the plugin from being
> activated if the version of PHP is below PHP 5-? What should a plugin do to
> not get activated? Meaning.. to signal to Wordpress that the activation
> should be cancelled.
>
>
>
> Raj
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list