[wp-hackers] Testing for PHP 5 before activating

John Eckman eckman.john at gmail.com
Mon Jul 12 14:26:43 UTC 2010


Otto - recently in wp-hackers you reposted this code, which I've seen posted before. 

I'm using it in wpbook (wordpress.org/extend/plugins/wpbook) but I'm still having an issue. 

Because my plugin uses try/catch syntax, the minute it gets uploaded, before the user can even activate it, they get a syntax error about an unexpected open curly brace {. 

Any suggestions on how to work around that?


On Jul 9, 2010, at 3:49 AM, Otto <otto at ottodestruct.com> wrote:

> /**
> * 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


----------------------------------------
John Eckman
eckman.john at gmail.com
http://www.johneckman.com/







More information about the wp-hackers mailing list