Fun with Uninstallation
Wednesday
Jan 9, 2008
There is a discussion going on over at Weblog Tools Collection about the difference between uninstalling, and deactivating, plugins. There are a lot of very good points made about the things that plugin authors can do to help maintain the WordPress user’s database.
To add to the discussion I have written a plugin that adds an uninstall option to the plugins page where there is a separate uninstall file included.
The file needs to have the same name as the plugin itself except but with the addition of _uninstaller on the end. So if the plugin is called my_plugin.php the uninstaller will be called my_plugin_uninstaller.php.

It will actually just include this file directly so it can’t echo anything to the browser. It can however register failure by redirecting back to the plugins page:
if ( $failure) { wp_redirect('plugins.php?uninstalled=false'); }
There are a number of things in this plugin that are a tad kludgy and so it isn’t something I intend to release unless an unexpected demand occurs, but it is one idea to add to the mix. Perhaps seeing something in action will give someone else some other ideas.
You can download it here: Fun with uninstallation 0.1
It comes with an empty uninstall file for hello dolly.
Update: With 40 comments to date it is clear that there is a demand for this. I have opened a ticket in the WordPress trac to gain feedback from developers and hopefully move things forward with similar functionality being included.
When I was building this I wanted to make it use a hook in the same way as a normal plugin would and I struggled to find a way to do it, which is why I went with a separate file; however, the trac discussion may have yielded a better alternative. If that is the case, I will amend this plugin to use that methodology and hope that it gets included in the core in one of the later point releases.
You can join in with that here:
http://trac.wordpress.org/ticket/5625
Update 2: This has now been superseded by this post, fun with uninstallation 2 and fun with uninstallation 3







Comments
Thomas Herold (http://www.dreammanifesto.com)
January 9th, 2008 at 11:47 pm
Great idea and absolutely useful. I like to see this as part of any plugin. One suggestion - I would place the uninstall part next to the deactivate space not as a full line beneath the box. This way it is more clear to which plugin it belongs.
Chip (http://blog.butterflymedia.ro/)
January 10th, 2008 at 12:04 am
Great. I needed this plugin, as some of my other plugins left some traces in my database. I will clean it and then report back to say how it went.
Andrew Rickmann (http://www.arickmann.co.uk)
January 10th, 2008 at 12:05 am
Thomas,
Unfortunately the plugin hook has been added after the row so I can’t include it in line. Otherwise I would have done.
Chip. It sounds like you may have got the wrong idea about what this does. This plugin is won’t do anything at all unless a plugin author decides to write their plugin with this in mind. It is intended to show some of the ideas discussed in the post I linked to. Apologies if I have misread your comment.
Rob (http://rmarsh.com)
January 10th, 2008 at 12:27 am
Andrew,
It’s a great idea but it really needs to be in the core. As it stands the benefit as a plugin developer of writing to use it is minimal until there’s any guarantee that users will have it installed. There really needs to be a single solution to the problem of full uninstallation.
Thanks though for giving us something to chew on.
Andrew Rickmann (http://www.arickmann.co.uk)
January 10th, 2008 at 12:38 am
Rob,
I completely agree.
danithew (http://www.blognitivedissonance.com)
January 10th, 2008 at 12:42 am
Great idea. I’d like very much to be able to uninstall directly from within WordPress.
Avi aka TikkunGer (http://www.jewsbychoice.org)
January 10th, 2008 at 1:13 am
Nice tool!!!
I think it’s a great idea and I hope it catches on!
Len
January 10th, 2008 at 1:22 am
I think there will be a big demand for this in light of the recent article at WTL. Currently I’m using Clean Option and the first time I ran it, it found over 300 orphaned items in the database! Not really sure if it actually approves database performance (much like using a registry cleaner on the Windows registry) but I’m fanatic about things like that.
I’ll give yours a shot as well. Can never have too many tools.
Jessi (http://jessibird.net)
January 10th, 2008 at 2:03 am
Brilliant! Hope plugin developers take advantage of this on their own initiative. If it becomes popular, perhaps it will make its way into the WordPress core.
BillH (http://www.benched42.net/)
January 10th, 2008 at 3:16 am
I understand that the existing plugin hook is to be displayed after the plugin row. How about changing the line that currently says: “Uninstall all the options and settings (including database tables) relating to this plugin.” to read “Uninstall all the options and settings (including database tables) relating to xxxxxxx.”
Brad (http://www.endperform.org)
January 10th, 2008 at 3:25 am
I think an uninstall plugin would go over well. I for one have a ‘messy’ WP database due to some leftovers from some plugins. I think if this functionality would remove things such as those, it would be a great thing.
andy cochrane (http://blog.theavclub.tv)
January 10th, 2008 at 4:51 am
while i fully applaud this tool, i kind of would prefer functionality like this rolled into the wordpress code itself. it would be extremely useful and nice to have wordpress move towards a mozilla-esque “extension” structure for plugins, wherein we can add, control, and remove plugins with as little stress as possible. this would help pretty much everyone- developers, site admins, and end users/visitors. so as a first step in a great direction, amen to this!
c. Wess Daniels (http://gatheringinlight.com)
January 10th, 2008 at 5:48 am
great idea. something I could have used a hundred times.
Dawn (http://www.flyingkiwis.co.nz)
January 10th, 2008 at 6:23 am
After reading the blog post “Uninstall - is there such a thing” (http://weblogtoolscollection.com/archives/2008/01/07/uninstall-is-there-such-a-thing/), I’m pleased to see you’ve created a plugin that will properly uninstall (as opposed to just remove or deactivate), I hope that plugin developers now start to include an uninstall with their plugins so we can use your plugin effectively.
I’ll defnitely be using it
Thanks!
Dawn
George
January 10th, 2008 at 6:45 am
I been looking for something like this now only if this was in the core file and not have to require plugin developer to write their code with this in mind.
Andrew Rickmann (http://www.arickmann.co.uk)
January 10th, 2008 at 8:07 am
BillH,
That’s a good idea and I will look at that.
burningHat (http://blog.burninghat.net)
January 10th, 2008 at 8:21 am
Oh great! I was looking for a plugin like this for a long time!
Thanks!
Kjetil Flekkoy - Italy (http://www.dolcevita.no/blogg)
January 10th, 2008 at 9:03 am
Would just say thanks.
Always good to be able to keep the system clean.
Kjetil
tabrez (http://beans.seartipy.com/)
January 10th, 2008 at 9:44 am
I too would vote for all the plugin authors forming a standard way to support plugin uninstallation and get as many wordpress plugins as possible compatible with Andrew’s tool.
Norbert Beckers (http://blog.norbertbeckers.nl)
January 10th, 2008 at 10:21 am
Thumbs up! I agree that this should be a feature of WP itself. implementation of this could be beneficial for a plugin like “TinyMCE Advanced” which now asks if you want to delete the toolbar presets you mode when you temporarily deactivate this plugin. This could be shifted to the uninstall feature.
Mads Christian Jensen (http://mads.eu)
January 10th, 2008 at 10:43 am
best plugin ever!
Paul (http://www.beentold.org)
January 10th, 2008 at 1:01 pm
Great idea - I’ve been following the discussion over at WLTC too and was very pleased to see someone doing something.
I agree this should be a core feature. But someone has to take a first step and you’re the one, it seems.
I’m not a WP developer, but maybe you could submit this idea to the folks who work with the core of WP?
I’m sure something of the sort will eventually have to become part of WP.
But untill it’s part of the core, there’s nothing stopping you from making this plugin (once it’s finished) available to developers and users. And maybe developers could make their future plugins “uninstall compatible” or something like that.
Alex :: Web Design (http://webdev.mysoutham.com)
January 10th, 2008 at 2:26 pm
This is definitely a step in the right direction, but what about the plugins that don’t have a separate uninstall file?
Andrew Rickmann (http://www.arickmann.co.uk)
January 10th, 2008 at 2:27 pm
Paul,
I have submitted this on the WordPress trac because I do think it is something that should be part of the core. One of the reasons why I am hesitant about releasing it is that there are other solutions that might be preferable.
The comments I have had are great but don’t really engage with the method of achieving the uninstall which means that although we now have an example of one method of achieving it we aren’t actually any closer to deciding that this is the way forward, i.e. that including a separate document. This is one issue that has already been raised on the trac, that it might be better to find a way of including the uninstall functions in the same plugin file.
Rob Marsh (http://rmarsh.com)
January 10th, 2008 at 4:36 pm
A solution that I would prefer is to use the usual deactivation hook but have the plugin admin page have a check box or a separate button so that a flag is set which the deactivation routine can use to decide whether to leave stuff intact or wipe the slate clean.
bdtmz (http://www.badtamiz.com/blog)
January 10th, 2008 at 4:37 pm
hello
a note of appreciation. we did want this, I always had to go through the database, real awsome work..
Pande (http://www.pandeblog.net)
January 10th, 2008 at 4:39 pm
Great Idea!
Andrew Rickmann (http://www.arickmann.co.uk)
January 10th, 2008 at 6:49 pm
Rob,
I did consider that option but I wanted it to be available when the plugin wasn’t enabled.
I think there are reasons why you might disable something and then after a period decide not to use it and it may be best not to have to activate it in order to uninstall it.
Bruce -- Harper Blue (http://harperbruce.net)
January 10th, 2008 at 8:19 pm
A good idea, whose time has long been here.
Keith (http://www.doubleblackdesign.com)
January 10th, 2008 at 9:57 pm
Andrew - The Wordpress Plugin Framework (WPF) that I developed allows for differentiating between deactivation and uninstallation of a plugin that has been developed using the WPF. I have provided a link to the latest version of the WPF below.
http://www.doubleblackdesign.com/2007/11/20/wordpress-plugin-framework-v004-released/
Basically, the WPF provides a “Deactivate Plugin” button to simply deactivate the specified plugin as well as an “Uninstall Plugin” button that removes the database entries associated with the plugin and deactivates the plugin.
David Lancelot Sjövall (http://www.alfacat.se)
January 10th, 2008 at 10:11 pm
Great initiative! I hope that we will se more uninstallation-plugins for WP in the future. Be proud that u made the first step creating one wp-uninstall-plugin!
Andrew Rickmann (http://www.arickmann.co.uk)
January 11th, 2008 at 12:11 am
Thanks Keith,
I think it is certainly an option, the only viable option at the moment, for developers to produce their own uninstall options and the WPF could be a massive help with that.
I think the best all round option is for the core to have an uninstall option as part of the plugins page that requires as little developer input as possible to operate.
Mike (http://www.ohmike.com)
January 11th, 2008 at 2:49 am
Fantastic idea. I was talking to Jeffro (who first pointed this out to me) not long ago.
It’s a great feature to have. Keep up the good work!
Matej Nastran (http://matej.nastran.net)
January 11th, 2008 at 10:52 am
Great thing! Yes, Wordpress would absolutely have to have a plugin uninstall function!
Keith (http://www.doubleblackdesign.com)
January 11th, 2008 at 12:51 pm
Andrew - I definitely agree with you that the uninstall feature should be integrated into the core of Wordpress just as the activate / deactivate feature currently is. I also feel that this should be taken a step further and that a standardized plugin framework like the WPF should be integrated as well to help minimize the difficulty in developing, administering and configuring plugins.
I have placed a request in the Wordpress Trac system to have the WPF (or something like the WPF) integrated into the Wordpress core.
http://trac.wordpress.org/ticket/5429
It may be of benefit to you to create a request for a basic uninstall feature as well.
Keep up the good work!
Andrew Rickmann (http://www.arickmann.co.uk)
January 11th, 2008 at 5:53 pm
I think that is a great idea Keith, I would like to see the WPF as part of the core.
Binh Nguyen (http://www.binh.name)
January 12th, 2008 at 8:20 am
I’ve been desperate for a a core feature of wordpress to uninstall plugins.
It’s so annoying for the plugins to leave some junk in the database after they are deactivated / deleted.
Thank you very much for making this plugin and if possible please make it into the core.
Regards,
Binh Nguyen
Craig (http://www.godponders.org)
January 12th, 2008 at 5:47 pm
What a great idea - this has been an issue - now if we could just implement some standards among the plug-ins.
Keep to the good work!
< Craig
Kevin (http://www.merchantamerica.com/cheaphosting/)
September 6th, 2008 at 10:05 pm
Great idea. I am suprised wordpress has not done this themself. Glad i found your site i will be checking out your other posts for more things i can use.