[wp-hackers] register_uninstall_hook VS uninstall.php
jayarjo at gmail.com
Fri May 7 18:09:52 UTC 2010
Unfortunately I can't use uninstall.php for my purpose. Or better to say it
would be kinda last resort.
I read the code now and understand what you mean... But, I still find it
pretty weird. Isn't it? Why would you need to store callback in the
database? Or why would you need to call it directly? Why not just to do
do_action('uninstall_' . $file ... and let the user to hook on this and do
whatever he/she finds appropriate? This could eliminate neccessity of using
function_name callback only, and could have been much more cleaner, logical
and convenient in general.
Ok, whatever is the reason behind such solution I don't get, but even if
there's one, I've found very nice workaround, which could work if only
WP_UNINSTALL_PLUGIN would have been defined for register_uninstall_hook
version too. Is there any reason why it's not?
On Fri, May 7, 2010 at 9:26 PM, Andrew Nacin <wp at andrewnacin.com> wrote:
> On Fri, May 7, 2010 at 1:20 PM, Azizur Rahman <
> prodevstudio+wordpress at gmail.com <prodevstudio%2Bwordpress at gmail.com> <
> prodevstudio%2Bwordpress at gmail.com <prodevstudio%252Bwordpress at gmail.com>
> > Like the uninstall.php to uninstall, can we use install.php or
> > activation.php for activation process?
> No. Those are much more flexible, as they are run either after activation
> before deactivation. They can be class methods, what have you. Uninstall is
> an exception, and so in 2.7 uninstall.php was introduced so uninstall
> scripts can be
> isolated and more robust.
> On Fri, May 7, 2010 at 1:19 PM, Davit Barbakadze <jayarjo at gmail.com>
> > Hmmm... dont' you think that there is something wrong with this
> > solution?
> Not one bit. Use uninstall.php if you want flexibility, or
> register_uninstall_hook if you
> want simplicity. Bottom line is, we're executing code when a plugin is not
> active, so we
> need to be nimble about it.
> On Fri, May 7, 2010 at 1:07 PM, scribu <scribu at gmail.com> wrote:
> > On Fri, May 7, 2010 at 7:56 PM, Dion Hulse (dd32) <wordpress at dd32.id.au
> > >
> > > And no, You cannot use array(&$this in uninstall hooks, the uninstall
> > > is stored within the database, its not determined at run time.
> > Actually, you can, but it causes an extra SQL query on each page load.
> From what I recall from #12754, it needs to be called statically. It's far
> better to
> use either a simple function, or even better, uninstall.php. And an extra
> SQL query
> on each page load is an obvious waste of resources.
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers