[wp-hackers] Testing for PHP 5 before activating

Kris Young KrisY at tbs.uk.com
Mon Jul 12 17:02:03 UTC 2010


Would have thought that a stern warning on the plugin download page would do enough. Especially in coding policy on WordPress 3, PHP4 is being slowly squeezed out.

Do you anticipate a lot of PHP4 users, or is it a 'better-safe-than-sorry' measure?

Kris

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Eric Mann
Sent: 12 July 2010 15:31
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Testing for PHP 5 before activating

John,
 
We'd need to see how your try/catch structure is formed to help you fix that
... 

On July 12, 2010 at 2:26 PM John Eckman <eckman.john at gmail.com> wrote:

> 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/
>
>
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
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