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

WordPress Trac noreply at wordpress.org
Mon Sep 25 16:40:22 UTC 2017


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

Comment (by adamsilverstein):

 [attachment:media-button-filter-example.diff] is an example use case for
 hooks in core. Note the red color of the patch as it simplifies what we
 have to do here... For the media widgets, when you click to insert media,
 we want it to read 'Insert into Widget' not 'Insert into Post'. Now,
 instead of having to overwrite the entire `mainInsertToolbar` function, we
 apply a filter which we can then use to alter the value on the fly.

 > would it not be a better architectural pattern to instead introduce
 hooks as something that can be instantiated onto a specific object

 @westonruter intriguing idea, i'm not sure it lets you remove hooks the
 way we want? The namespaces is mostly so you CAN easily remove hooks by
 name (no matter who added them), a requirement that was brought up during
 development.

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


More information about the wp-trac mailing list