[wp-hackers] register_uninstall_hook VS uninstall.php

Dion Hulse (dd32) wordpress at dd32.id.au
Fri May 7 16:56:53 UTC 2010

Basically, Your plugin shouldnt run any PHP upon inclusion OTHER THAN

/* header..*/


Is Good.

This is bad:
/* header..*/

if ( strpos(.....) )
if ( something )
  include somethingelse.php


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

More information about the wp-hackers mailing list