[wp-hackers] register_activation_hook and PHP closure

Lionel POINTET lionel.pointet at globalis-ms.com
Thu Apr 26 08:11:32 UTC 2012


I don't think it's more clean and readable than a good and expicit method
name, that doesn't force you to read the code put in a closure to
understand what it's made on that hook.

Plus, if you're designing a plugin that may be released in the WordPress
repo, you should let your users decide to let your hooks in place or not.
You should maybe take into account that everybody doesn't have PHP >= 5.3
and that methods will break with the older platforms...

But if you're developing a plugin for your own needs, make it the way you
want, of course.

2012/4/26 Ryan Chan <ryanchan404 at gmail.com>

> On Wed, Apr 25, 2012 at 11:58 PM, Eric Mann <eric at eam.me> wrote:
> > Just for the record, registering hooks using closures is typically a bad
> > idea because they can't be removed later with `remove_action()`.
> >
>
> Yes, but using closures made the code more clean and reabable. We
> don't use remove_action in our own plugin.
>
> Thanks all for your feedback.
> _______________________________________________
> 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