[wp-hackers] Stop activation request
DD32
wordpress at dd32.id.au
Thu Feb 7 02:38:02 GMT 2008
I cant find my previous posting on it..
But, As of 2.4/2.5 at least its easier to deactivate a plugin.
http://trac.wordpress.org/ticket/5210
Simply register a activation hook:
register_activation_hook(__FILE__, 'plugin_Activation_hook_here');
function plugin_Activation_hook_here(){
if( <Check if other plugin is installed> || <Check PHP extension required is installed> ){
return; //Return, let the plugin activate.
} else {
//A requirement isnt met!
deactivate_plugins(__FILE__); //Deactivate ourself
wp_die("ERROR! You have not met a requirement of this plugin"); //add a more descriptive message of course.
}
}//end function
In 2.3 you need to do some array funky-ness to remove the plugins file from the active_plugins option array as the deactvate_plugins() function doesnt exist.
On Thu, 07 Feb 2008 13:05:19 +1100, Peter <peter at avirtualhome.com> wrote:
> I am wondering if there is a way to stop and activation request.
> Example:
> A user clicks on activate in the admin->plugin menu
> The script does a register_activation_hook($file, $function)
>
> In the function there will be tables created but when they fail you
> should see an error message, like the message when it succeeds but with
> an error and the plugin isn't activated.
>
> I hope it makes sense.
>
More information about the wp-hackers
mailing list