[wp-hackers] readme.txt: "Requires PHP 5 tag"

Geoffrey Sneddon foolistbar at googlemail.com
Fri Jul 17 21:11:13 UTC 2009


On 14 Jul 2009, at 22:41, Otto wrote:

> Don't rely on users, they're invariably idiots. ;)
>
> Make your plugin smarter instead.
>
> /**
> * 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');

But if you use PHP 5 only syntax, you'll have a fatal error thrown and  
thus that code will never be executed.


More information about the wp-hackers mailing list