Way back in the mists of time, following an article on Weblog tools collection, I started looking at writing an uninstaller for WordPress plugins. There was a significant interest in this at the time so I wrote a patch and submitted it to core where it stayed for some time.
The process was documented in three posts: Fun with uninstallation part 1, part 2 and part 3. Note that the sample plugins that are linked to in these posts have been removed as some users were misunderstanding them and using them despite the fact that they were practically useless.
My hope that the patch would be included in WordPress 2.5 was not to be. 2.6 has also been released. Finally though, thanks to Jacob Santos who pushed it along, with 2.7 it will be possible for plugin authors to write an uninstall routine.
The final implementation is actually closest to my first attempt. It bypasses the problem of creating hooks in a plugin that will not be active and does not add to the core more than it has to.
To produce the uninstaller you need to include a separate file (uninstall.php) within the plugin folder. This should include all the code needed to remove options, database tables, etc.
This file will be run when the plugin delete routine runs, so it will not be possible to uninstall the plugin without deleting it. If the plugin is deleted manually, using FTP, then the plugin will need to be re-uploaded before anything can be uninstalled.
Given that WordPress 2.7 will include a plugin installer that will let you search for and install plugins directly from the plugin repository without any FTP shenanigans it is reasonable to presume that users will usually delete the plugin through the interface as well.
I think that users might want to uninstall a plugin in order to wipe the settings so it may not be a bad idea to write the uninstaller in a way that allows it to be run manually and to trigger the plugins activation function to reinstall the defaults. I am working on an implementation of this for the next version of my fun with plugins tool.
(__)
`
User links about “uninstaller” on iLinkShare
[...] | user-saved public links | iLinkShare 3 votesWordPress plugin uninstaller>> saved by asalinasci 1 days ago2 votesAshampoo UnInstaller 3.10>> saved by suburbandestiny 2 days [...]
(__)
`
What’s new and exciting? | WP FUN
[...] have already written about the plugin uninstall mechanism so I won’t go into that again but it is interesting. Back in the days of 2.3 there was a lot [...]
(__)
`
Vladimir Prelovac
I like the idea of a separate file as this will provide plugin compatibility for previous versions of WP.
Adding the option to selectively run uninstaller is not a bad idea as sometimes you want to leave the plugin on the server but do not want any traces of it in the database.