[wp-hackers] PHP 5 any time soon?

Otto otto at ottodestruct.com
Mon Jan 25 16:29:08 UTC 2010


On Mon, Jan 25, 2010 at 10:09 AM, Andrew Nacin <wp at andrewnacin.com> wrote:
> As said, there are things that trump developer convenience, but there's
> nothing stopping a plugin developer from forcing a PHP 5 requirement, which
> is quite easy to do. (You can even throw a fatal error and prevent the
> plugin from ever being activated.) In fact, many encourage that, as a way to
> ease people to (bother their hosts to transition to) PHP 5 and to reduce a
> burden on the developer.

I've been doing this or similar for a while now:

// require PHP 5
function plugin_activation_check(){
	if (version_compare(PHP_VERSION, '5.0.0', '<')) {
		deactivate_plugins(basename(__FILE__)); // Deactivate ourself
		wp_die("Sorry, Plugin Name requires PHP 5 or higher. Ask your host
how to enable PHP 5 as the default on your servers.");
	}
}
register_activation_hook(__FILE__, 'plugin_activation_check');

I also add checks to that for specific functions when a plugin needs
specific support for them, but the fact is that PHP 4 is simply dead
tech. Nobody really supports it anymore. More and more hosts are
starting to change their defaults to PHP 5. I see no reason to
continue to support that 1% of hosts that don't offer PHP 5 support.

-Otto


More information about the wp-hackers mailing list