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

A Walker photofantaisie at live.fr
Sat Nov 1 23:09:32 GMT 2008










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


More information about the wp-hackers mailing list