[wp-hackers] Plugin uninstall/deactivate in 2.7 vs 2.6

A Walker photofantaisie at live.fr
Sun Nov 2 05:30:15 GMT 2008



Jacob,

I did read your article several times :-) but I hadn't realised that the WP_UNINSTALL_PLUGIN constant is created at uninstall, not at activation.

Thanks DD32, I'll use your method. :-)

Thanks again.

Ade.

> Date: Sat, 1 Nov 2008 22:11:51 -0500
> From: wordpress at santosj.name
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Plugin uninstall/deactivate in 2.7 vs 2.6
> 
> Sigh, I wrote about this on my blog when ever it was first introduced, 
> but I guess many missed that. No worries, Frank's article appears to be 
> better written.
> 
> Your code will not work the way you think. The constant 
> WP_UNINSTALL_PLUGIN does not exist until uninstall. It is something you 
> look for the existence of, not the lack of existence of.
> 
> For backwards compatibility, you should use the method that DD32 wrote 
> about in his reply.
> 
> Jacob Santos
> 
> A Walker wrote:
> > Having read Frank's excellent article here: http://wpengineer.com/wordpress-plugin-deinstall-data-automatically/ I think I understood much better how the plugin uninstall routines work in 2.7. Thanks Frank!
> >
> > It seems to me that for 2.7+ the register_deactivation_hook is no longer required provided the plugin author provides an uninstall.php file with the appropriate code. So, I was wondering about adding some backwards compatibility for 2.6 etc, so that the plugin's options are deleted from the db if a user with less than 2.7 decides to deactivate the plugin. I tried adding this to my plugin, but found that the deactivation hook was still being registered under WP 2.7 beta 1:
> >
> > <code>if ( !defined ( WP_UNINSTALL_PLUGIN ) ) {
> > register_deactivation_hook(function to delete options...)
> > }</code>
> >
> > Then, create an uninstall.php with delete_options(blah blah) for 2.7+. 
> >
> > In case I haven't explained myself very well (probably not, lol) the idea is to only register the deactivation hook if the plugin is installed on WP 2.6 and below.
> >
> > I'm scratching my head on this, and if anyone can point out where I've overlooked the obvious - please do! Thanks!  :-) 
> >
> > Ade.
> > _________________________________________________________________
> > Découvrez la nouvelle génération des servives de Windows Live
> > http://get.live.com_______________________________________________
> > 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

_________________________________________________________________
Rejoignez la nouvelle famille de Windows Live Messenger
http://get.live.com


More information about the wp-hackers mailing list