[wp-hackers] register_uninstall_hook VS uninstall.php

Davit Barbakadze jayarjo at gmail.com
Fri May 7 17:19:19 UTC 2010


Hmmm... dont' you think that there is something wrong with this (current?)
solution?

On Fri, May 7, 2010 at 8:56 PM, Dion Hulse (dd32) <wordpress at dd32.id.au>wrote:

> Basically, Your plugin shouldnt run any PHP upon inclusion OTHER THAN
> add_action/add_Filter()
>
> <?php
> /* header..*/
>
> add_action('....
> register_uninstall_hook...
> ?>
>
> Is Good.
>
> This is bad:
>  <?php
> /* header..*/
>
> if ( strpos(.....) )
>  wp_redirect(....
> if ( something )
>  include somethingelse.php
>
> add_action('....
> register_uninstall_hook...
> ?>
>
> And no, You cannot use array(&$this in uninstall hooks, the uninstall hook
> is stored within the database, its not determined at run time. Your plugin
> will not recieve init/plugins_loaded/admin_init, etc hook firings when the
> uninstall hook is called, Its a pure "Heres some SELF CONTAINED code to run
> to clean up"
>
> On 7 May 2010 09:52, Davit Barbakadze <jayarjo at gmail.com> wrote:
>
> > Can anyone explain a bit more deeply, what is meant in the paragraph
> below?
> > Especially in the part about "The plugin should not run arbitrary code
> > outside of functions"?
> >
> > "The plugin should not run arbitrary code outside of functions, when
> > registering the uninstall hook. In order to run using the hook, the
> plugin
> > will have to be included, which means that any code laying outside of a
> > function will be run during the uninstall process. The plugin should not
> > hinder the uninstall process. "
> >
> > http://codex.wordpress.org/Function_Reference/register_uninstall_hook
> >
> > There is always some code inside the plugin right?
> register_uninstall_hook
> > looks more convenient, 'cause for example I use variable in option and
> > table
> > names, which depend on the classname of the plugin, or for example I want
> > to
> > use variables form within my plugin to check some conditions before
> > uninstalling. And by the way can I use array($this, 'callback') type of
> > callback in register_uninstall_hook?
> >
> > --
> > Davit Barbakadze
> > _______________________________________________
> > 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
>



-- 
Davit Barbakadze


More information about the wp-hackers mailing list