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

Otto otto at ottodestruct.com
Tue Jul 14 20:41:56 UTC 2009


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');



-Otto



On Tue, Jul 14, 2009 at 12:31 PM, Lutz Schröer<latz at elektroelch.de> wrote:
> I've decided to use exclusively PHP5 in my new plugin version since it was
> much easier to code it using the PHP5 features. Unfortunately many users
> seem to have no access to webspace with PHP5 (five years after PHP5 was
> released!).
>
> I have prevented people from updating through the backend programmatically
> but those who are downloading the plugin from wordpress.org and installing
> it manually often do not read the readme.txt and wonder about a "Parse
> error: syntax error, unexpected T_CLASS".
>
> How about adding a "Requires PHP version x.xx" tag to the readme.txt that
> will be displayed on the extend pages? And maybe the backend could evaluate
> this tag, too, and disable the update if the installed version does not fit.
>
>
> ... and even if this topic has been discussed a thousand times: Let's drop
> the PHP4 support!
>
> Latz
>
> _______________________________________________
> 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