[wp-hackers] Uninstall Handling

Dion Hulse (dd32) wordpress at dd32.id.au
Sat Apr 9 03:00:48 UTC 2011


There's a difference between the Deactivation hook and the Uninstall hook.
The uninstall hook runs when you use the "Delete Plugin" functionality, The
deactivation hook runs when you, well, deactivate the plugin.

The good thing about the Uninstall hook, is that your plugin does not need
to be activated in order to use it, whereas, the deactivation hook (and
therefor, the option pages wit ha uninstall checkbox..) need to be activated
before it can be used.

Now, Back to Ken's problem..
Ken, What is the flow you're trying to get working exactly? Do you want some
kind of UI steps in the uninstall process?
The uninstall hook/file is designed that you simply run the code to clean up
after yourself, no questions asked.  You'd use this style to remove any
cached data in the database, and non-default options. Some people might have
a want to keep the user settings in the install (in which case, you'd set to
them to autoload=no) - but most people will remove all data, including user
settings (which is recommended as a thorough cleanup)


On 9 April 2011 12:14, William P. Davis <will.davis at gmail.com> wrote:

> I personally support this approach, actually — I think it's a bad idea to
> delete tables, destroy options, etc. on deactivate. What if you're just
> momentarily deactivating to test something — if you delete everything on
> deactivation you will lose everything. Instead, having a sort of "hard
> uninstall" that destroys all your data makes sense to me.
>
> will
> Sent from my BlackBerry® wireless device
>
> -----Original Message-----
> From: Andrew Nacin <wp at andrewnacin.com>
> Sender: wp-hackers-bounces at lists.automattic.com
> Date: Fri, 8 Apr 2011 20:05:09
> To: <wp-hackers at lists.automattic.com>
> Reply-To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Uninstall Handling
>
> On Fri, Apr 8, 2011 at 8:00 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
>
> > What I do is at the bottom of my options page for my plugins I have a
> > check box, labeled 'Uninstall on Deactivation'.  When the user clicks
> > that and saves the options that sets an uninstall flag in my plugin
> > options.  When the user deactivates the plugin I have a deactivation
> > hook that runs, that will check for that uninstall flag and if set
> > will then proceed to delete all the options and stuff associated with
> > my plugin.  I don't personally include any code to delete my plugin
> > files, thats simple enough for them to do from the plugin manager.
>
>
> I really don't understand that approach at all. You're adding an
> unnecessary
> and inconsistent UI option rather than leveraging the consistent uninstall
> process that WordPress provides plugin authors.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list