[wp-hackers] wp_die vs hooking into admin_notices

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Jan 28 22:25:30 UTC 2011

On Sat, 29 Jan 2011 04:04:01 +1100, fris <fris at fris.net> wrote:
> function curl_check(){
> 	if (!function_exists('curl_init')) {
> 		deactivate_plugins(basename(__FILE__));
> 		add_action('admin_notices','curl_notice');
> 		//wp_die("Sorry, but this plugin requires CURL.");
> 	}
> }
> wp_dir or hook a function into admin_notices?

Well that certainly won't work.. As the activation happens on a page load,  
which is then redirected to the plugins page. So by the time you hit a  
page which admin_notices is firing on, you'll have already deactivated  
your plugin.

Personally, I'm a fan of the die on activation, which ultimately displays  
a message "This plugin could not be activated due to an errror... <output  
 from plugin>"

A better way however, Is to run the plugin in 2 forms, The Bootstrap, and  
the actual plugin; the bootstrap is the file with the plugin header, it  
includes no advanced code or specific requirements, all it does is check  
the environment is compatible with the plugin, then either a) includes the  
main plugin file (which contains the code which requires things) or b)  
doesnt include the plugin code, and instead, just adds an admin notice or  

That being said, in this case, loose your requirement on curl, Whilst it's  
probably just one of the requirements you've got, use WP_HTTP for that  
particular use, it has many advantages over simply using curl.

Dion Hulse / dd32
  e: contact at dd32.id.au
  Web: http://dd32.id.au/

More information about the wp-hackers mailing list