[wp-hackers] Uninstall Handling

Ryan Bilesky rbilesky at gmail.com
Sat Apr 9 00:00:32 UTC 2011


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.

On Fri, Apr 8, 2011 at 3:35 PM, Ken Brucker <Ken at pumastudios.com> wrote:
> Eric,
>
> That's a good option.  I was trying to leverage the support already in place in WP as documented here:
> https://codex.wordpress.org/Function_Reference/register_uninstall_hook
>
> Feels like re-inventing the wheel to have to put an 'uninstall' option into the plugin options page.  Core will almost do what is needed and other authors that do use the documented method fall into the same trap.  If the admin doesn't want to, or can't, supply FTP login information it's not possible to get to the uninstall handling built into the plugin.  This seems like a design flaw.
>
> ps.  Just so happens I posted an answer to a question of yours on stackexchange re: WP Rewrite right before reading your response below.  :)
>
> On Apr 8, 2011, at 5:15 PM, Eric Mann wrote:
>
>> Ken,
>>
>> In the past, I've seen developers place an "Uninstall" link on the plugins
>> page for their plugin.  Then they bind any uninstall scripts to this link
>> and also deactivate the plugin at the same time.
>>
>> Is that the kind of setup you're looking for?  I'm not sure what else you're
>> trying to accomplish or how you're trying to do it.
>>
>> On Fri, Apr 8, 2011 at 2:54 PM, Ken Brucker <Ken at pumastudios.com> wrote:
>>
>>> Hi all - been lurking for a while, first time asking a question here.
>>>
>>> I'm trying to cleanup a bunch of stuff that gets put into the database
>>> related to a plugin I'm writing but am stymied by the flow in
>>> delete_plugins().  I've got my uninstall.php file setup and have found that
>>> unless I provide FTP login information during the Delete operation I can't
>>> get to the point that the uninstall script will run.
>>>
>>> Should I open a bug in the tracker to have the delete_plugins() flow
>>> improved to allow the uninstall process to run separate from the file
>>> deletion?  I really want to clean the database and don't want (or need) WP
>>> to go do the actual file deletion.
>>>
>>> And any thoughts on how to get my uninstall to run given the current state
>>> of the logic?
>>>
>>> I don't want to do the cleanup when the plugin is deactivated since there
>>> are many reasons to deactivate on a temporary basis.
>>>
>>> -- Ken
>>>
>>>
>>> _______________________________________________
>>> 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
>
> _______________________________________________
> 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