[wp-trac] [WordPress Trac] #21170: JavaScript actions and filters

WordPress Trac noreply at wordpress.org
Sat Jul 22 13:00:02 UTC 2017


#21170: JavaScript actions and filters
-----------------------------+------------------------------
 Reporter:  koopersmith      |       Owner:  adamsilverstein
     Type:  feature request  |      Status:  assigned
 Priority:  normal           |   Milestone:  4.9
Component:  General          |     Version:  3.4
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:  javascript
-----------------------------+------------------------------

Comment (by azaozz):

 Replying to [comment:132 jnylen0]:
 Generally I think lambda functions suck when you're writing code that is
 supposed to be easy to extend.

 > In the plugins repo there are about 6500 instances of plugins...

 That may be but these plugins are already incompatible with all WordPress
 installs (no closures support in PHP 5.2).

 > Maybe, but sacrificing the very natural JavaScript pattern `add_filter(
 'some_filter_name', function() { ...` doesn't really seem worth it to me.

 If you feel strongly about that, lets go with the jQuery pattern instead
 of a separate arg. See my
 [https://core.trac.wordpress.org/ticket/21170?replyto=132#comment:131
 previous comment].

 > I'm in favor of requiring that core JS filters always have a namespace
 or function name, but not so sure about making these mandatory for
 plugins.  I think it would add a significant amount of friction for a
 fairly minor use case.

 Then we will have many hook that are removable and some that are not?
 Don't think "partial support for removing actions and filters" is a good
 thing. Having said that, there may be a need for non-removable hooks, both
 for core and plugins. However if we are going to implement that I'd prefer
 to see it as another arg rather than as optional namespace, mostly for
 clarity/readability.

 > Either way, PHP parity is not something we should necessarily strive
 for...

 I agree. I don't really care about PHP or JS or any other particular
 language. I just want to keep features that have proven useful over the
 years, and maybe improve them a bit if possible.

 Being able to control which actions and filters run at a particular time
 is a pretty important thing imho. Also, I'm tired of having to add "Doing
 it wrong.." in more and more places. All of these usually indicate some
 requirement that was missed when implementing a feature. Look at
 shortcodes... :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/21170#comment:133>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list