[wp-hackers] anonymous functions for do_action and apply_filters

Brian Layman bulk at thecodecave.com
Mon Dec 20 21:40:32 UTC 2010


On 12/20/2010 3:49 PM, Nathaniel Taintor wrote:
>> >  have any of you guys discussed about adding the possibility to use php
>> >  anonymous functions [1] with the hooks?
> I think its generally frowned upon, because if you add an anonymous
> function, then you have no way of removing it, other than calling
> remove_all_filters.
Agreed.

Sure, I've seen anonymous functions used in some valid callback functions.

The only time I've seen lambda used with hooks was to mask a malware 
infestation.  So it leaves a bad taste in my mouth.

I'd much rather see straight forward code than clever/tricky code in the 
plugins and themes I review.

Then I can be sure I know that both me an the original author know 
exactly what the code is really going to do.

-Brian


More information about the wp-hackers mailing list