[wp-trac] [WordPress Trac] #21170: JavaScript actions and filters
WordPress Trac
noreply at wordpress.org
Mon Jul 24 12:35:57 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 jnylen0):
Replying to [comment:136 azaozz]:
> It's not hard to check for a dot in the hook name or if the callback is
a string.
Supporting string callbacks doesn't make sense in JavaScript - you should
just pass the function directly instead. Functions also have a `name`
[https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Function/name property]
which we can check.
> However for ease of use/clarity it would probably be better to always
require a jQuery-style namespace.
Then we are back to this point, again for ease of use/clarity:
> if we do make [the namespace] mandatory, then it should be a separate
argument (at that point there's no reason to include it in the "hook name"
argument and then have to split apart that string).
Possible solutions so far:
- Always require a jQuery-style namespace.
- Always require '''either''' a jQuery-style namespace '''or''' a function
name.
- Add a separate, required argument for hook name.
- Decide that `forEachFilters` provides enough of this functionality for
us to be OK with not having mandatory names.
I have to say that none of these really feel right to me. I will keep
thinking about it; other suggestions welcome.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21170#comment:137>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list