[wp-trac] [WordPress Trac] #21170: JavaScript actions and filters
WordPress Trac
noreply at wordpress.org
Fri Jul 21 09:37:16 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:130 jnylen0]:
> However, I'm not sure we should make it mandatory.
Thinking it should be mandatory so we have parity with the way hooks work
in PHP. A plugin should always be able to remove an action or a filter,
also when it is added by another plugin. If the callback name is not
mandatory some plugins will probably skip it. Then we will have to do "Not
doing it right.." etc. again.
Working example:
{{{
function my_func() {
remove_filter( 'the_content', 'wpautop' );
}
add_action( 'init', 'my_func' );
}}}
This is very straightforward, a plugin removes a core filter. Then another
plugin can do:
{{{
function my_func_2() {
remove_filter( 'init', 'my_func' );
}
add_action( 'init', 'my_func_2', 1 );
}}}
Being able to do these things with all hooks is very important for both
core and plugins.
> ...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).
I don't have strong preference here. Being in the "hook name" follows the
jQuery pattern that is very well known. However this is optional in
jQuery. Making it a second argument will convey better that it is
required.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21170#comment:131>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list