[wp-hackers] Best way to abort Plugin installation

Matt Jacob matt at mattjacob.com
Sun Mar 28 14:53:38 UTC 2010


On 3/27/10 3:53 AM, TobiasBg wrote:
> So this means, that you allow the plugin to actually get activated
> (in the WP sense), it just has no functionality if those checks
> aren't fulfilled (because the bootstrapper doesn't load the plugin's
> core)?

Right. It gets activated and it shows the error message in the admin 
until the user upgrades their setup or deactivates the plugin.

> Doesn't that mean that the checks are performed on every page load?

Yes, but it's not like the checks are computationally intensive. PHP 
will recall its version pretty readily, and checking for the existence 
of PHP modules or their version uses hardly any resources at all.

> Do you have sample code to share? Or maybe the link to your plugin in
> the repository?

Here's a shortened link for email wrapping:
http://ma2t.me/h

Check out pingfm-bootstrap.php for the gist of it. It's more or less 
just a single conditional (simple example):

if (version_compare(PHP_VERSION, '5.1.0', '<')) {
     add_action('admin_notices', 'wp_pingfm_php_version');
}
else {
     require_once(dirname(__FILE__) . '/pingfm-class.php');
     require_once(dirname(__FILE__) . '/pingfm-tags.php');

     // Instantiate the object and let's get rolling!
     $wp_pingfm = new WP_PingFmCustomUrl(__FILE__);
}

I'm sure someone else must be doing the same thing, or at least 
something very similar...

Matt


More information about the wp-hackers mailing list