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

WordPress Trac noreply at wordpress.org
Tue Nov 21 12:40:35 UTC 2017


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

Comment (by adamsilverstein):

 @gziolo Thanks for your work on this, that PR looks great and I will try
 to test it out.

 Since this merge/revert here the code has only changed slightly, in this
 PR we changed the way hooks can be added to a project via composition
 (from npm): https://github.com/WordPress/packages/pull/40.

 The hooks package now exports a `createHooks` helper:

 Hooks can thus be added to an object via composition:
  `import createHooks from '../';`
  `myObject.hooks = createHooks();`
  API functions are then be called: `myObject.hooks.addAction()`

 The current plan for core is to experiment with adding hooks for
 extensibility of media and other JavaScript components and decide how to
 expose them. For a platform like WordPress core, it probably makes the
 most sense to expose hooks as a global as the previous patch did, eg.
 `wp.hooks = createHooks();` while plugins may choose to their own
 namespace hooks, eg. `myPlugin.hooks = createHooks();`

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


More information about the wp-trac mailing list