[wp-trac] [WordPress Trac] #33492: Slightly better add_filter

WordPress Trac noreply at wordpress.org
Sat Aug 22 13:16:19 UTC 2015

#33492: Slightly better add_filter
 Reporter:  Iazel        |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:

Comment (by dd32):

 Replying to [comment:2 Iazel]:
 > Sorry, but I don't see how this could raise more conflicts than using
 the named functions, furthermore if you use the plugin domain, that should
 be unique for every installed plugin as far as I know, hence it's
 impossible to have a name conflict.

 Since we can't enforce it that other plugins won't have a similarly named
 function, or that plugin authors would use their plugin slug, that raises
 the possibility of conflicts. Sure, it's a small case, but it's one that

 > I also don't see why anonymous function should be discouraged, this kind
 of use case is the perfect one for them!
 I'm not saying they should be discouraged, but that in some situations,
 they should be avoided in favour of a class method or stand alone
 function. Yes, in your use-cases they probably make sense, and I'm not
 arguing against that.

 > Obviously we can store it in a variable, but in the 99% of the case,
 that variable will be out of scope for another plugin/template to replace
 it, and that's the usual case.

 And that's a use-case where I feel that an anonymous function should be
 discouraged, where it's hooked in one place, and unhooked in another
 context. Personal opinion though.

Ticket URL: <https://core.trac.wordpress.org/ticket/33492#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list