[wp-hackers] Testing for PHP 5 before activating

Eric Mann eric at eamann.com
Mon Jul 12 14:31:22 UTC 2010


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


More information about the wp-hackers mailing list