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

WordPress Trac noreply at wordpress.org
Mon Jul 24 08:12:30 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:134 jnylen0]:
 > We can always take away restrictions later; adding new restrictions is
 more problematic.

 Exactly. Adding restrictions after an API has been "released" and used by
 plugins is pretty much impossible in WordPress.

 Replying to [comment:135 adamsilverstein]:
 > Note that we have `removeAllFilters( 'filtername' )` and
 `removeAllActions( 'filtername' )` which enables removing all hooked
 callbacks (without knowing what they are)...

 Yes, but that's not that useful, can even be quite "dangerous". You'll
 never know what hooks will be removed. Imagine what would happen if all
 hooks from `'init'` are removed :)

 > > Implement jQuery-style namespaces.
 > > Require either a namespace or a function with a name.
 >
 > Both sound good if we can figure out how to enforce that requirement.

 Yeah, been thinking about that too. It's not hard to check for a dot in
 the hook name or if the callback is a string. However for ease of
 use/clarity it would probably be better to always require a jQuery-style
 namespace. I.e. all callbacks will have to be "named" in the hook name.
 The chars for that "callback name" should also be restricted imho.
 Something like `/[a-zA-Z0-9_-]+/` should work well. That takes care of
 several things at the same time: sanitization, readability, etc.

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


More information about the wp-trac mailing list