[wp-trac] [WordPress Trac] #46991: Stop propagation on actions or filter

WordPress Trac noreply at wordpress.org
Mon Apr 22 08:59:10 UTC 2019

#46991: Stop propagation on actions or filter
 Reporter:  screamingdev                   |       Owner:  (none)
     Type:  feature request                |      Status:  new
 Priority:  low                            |   Milestone:  Awaiting Review
Component:  Plugins                        |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  reporter-feedback 2nd-opinion  |     Focuses:

Comment (by screamingdev):

 Surely I can make up some use cases either small and big or simple and
 important. So I just point out that this leads to a better event-based-
 system (as possibly known from other languages or frameworks) and give an
 example for action and filter. I am sure there is a need among developers
 to stop WordPress or other plugins/themes from doing things. Currently
 noone has granular control over the things that happen in the event queue
 / hooks and deregister all remainder or the whole action/filter is no
 proper solution.


 add_filter( 'wp_footer' , function () {
   if ( is_sales_page( 'footer' ) ) {
     echo get_page( 'footer-salespage' );
     // stopPropagation
 } );

 Yee this can be done in the template too and I just made up functions.


 add_filter( 'register' , function () {
   // stopPropagation
 } );

 We simply disable something.


 On the one hand this solves all the scenarios where customers needs
 changes for their own site. So if WordPress wants to become or name itself
 kind of "framework" with event sourcing then it truly should be capable of
 stopping events.
 On the other hand this blocks out plugins and theme-functionality which is
 fine because someone truly intended to.

 This can be solved in multiple ways:

 * add stopPropagation (and keep it in WordPress)
 * Allow a dropin for WP_Hook
 * Do not make WP_Hook a final class

 What else do you like to discuss?

Ticket URL: <https://core.trac.wordpress.org/ticket/46991#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list