Fun with Uninstallation

Plugin Status Stable
Author Andrew Rickmann Version 0.2
Plugin Home Visit Author Homepage Visit
Download Visit Plugin License Others
Description :
Adds an uninstall hook


Adds an uninstall hook
The plugin author needs to do two things. The first is to add an uninstall option at the top of the plugin file, somthing like this:
Posted: 11th Jan 2008, in: plugins - Older Post - Newer Post

After reading the comments on my first uninstallation plugin attempt, and the WordPress Trac, it become clear that the approach of using an external file probably wasn’t going to cut it. So I have taken that on board and produced a revised version.

I think version 0.2 is a significant step forward, not least because it solves the problem of needing a separate file.

So how does this version work?
The plugin author needs to do two things. The first is to add an uninstall option at the top of the plugin file, somthing like this:

if ( !is_plugin_active( __FILE__ ) ) {

class my_plugin{

function uninstall(){

}
}

return;
}What this does is to only expose the uninstall methods if the plugin is not active, and further, the addition of the return at the end stops the rest of the plugin being loaded.

Important Note: An inactive plugin is only loaded if it is in the process of being uninstalled. It will not be loaded at any other time and so won’t impact on performance or security any more than they already do.

The second thing the plugin author needs to do is to register the uninstall function. This should be done when the plugin is activated. The function that needs to be called is:

Similar Plugins

One Response to “Fun with Uninstallation”

  1. Andrew Says:

    Please do not use this plugin. This plugin is a proof of concept intended to illustrate a potential method of adding functionality to WordPress.

    It is not, and never was, intended for distribution, or for general use.

    Please read the full, unedited, series of posts on wp-fun.co.uk for details of what this is, what is does, and why the final solution is not as explained on this page.

Leave a Reply