[wp-trac] [WordPress Trac] #41422: Need replace_filter() function for improved Just In Time filter adjusment

WordPress Trac noreply at wordpress.org
Tue Jul 25 08:40:08 UTC 2017


#41422: Need replace_filter() function for improved Just In Time filter adjusment
-------------------------+------------------------------
 Reporter:  bobbingwide  |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Formatting   |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by azaozz):

 Replying to [comment:2 bobbingwide]:
 > I might not have proposed this solution had priorities been used
 correctly in the first place.

 I understand, but fixing a (minor) bug by extending the API is.... perhaps
 an overkill? :)

 As far as I see disabling and then enabling a hook is pretty similar to
 removing and then re-adding a hook. The only (meaningful) difference is
 that it keeps the "order of loading" sub-priority which shouldn't matter
 in the first place if priorities are used properly. If they are not, lets
 fix them.

 So this adds a second "priority" thing which is starting to get confusing:
 remove_action, disable_action, remove_disabled_action,
 enable_removed_action, ... etc.

 I agree `replace_action` may be useful in some cases. Perhaps we can add
 that and leave it to plugins if they want to do the disable/enable stuff
 themselves (i.e. replace an action with a noop callback for some time)?

 In any case a plugin can always do:
 {{{
 remove_filter( 'the_content', 'wpautop' );
 remove_filter( 'the_content', 'balance_tags' );
 ....
 add_filter( 'the_content', 'wpautop' );
 add_filter( 'the_content', 'balance_tags', 15 );
 }}}

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


More information about the wp-trac mailing list