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

WordPress Trac noreply at wordpress.org
Tue Nov 19 22:47:21 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:  2nd-opinion      |     Focuses:
-----------------------------+------------------------------

Comment (by mbabker):

 A practical use case where a `stopPropagation` type of function call would
 be beneficial.

 I've written an import system to move a client's multiple websites from
 another platform to WordPress, and the import plugin makes liberal use of
 filters to be able to make site specific modifications to the imported
 data without stuffing it all in the core plugin.  Part of this includes
 the ability for one of the hooks to cancel the import of a line of data
 from the import file.  Because of the lack of a way to stop propagating
 the call down to later priority hooks, all of the hooking functions need
 to check if the import has already been cancelled for that line and behave
 differently, whereas with a `stopPropagation` type of call the hook that
 cancels the request could just tell WordPress I don't want it to call
 anymore hooks.

 I could get around this locally by throwing Exceptions if I had to, but I
 couldn't find anything inside `wp-includes/plugin.php` that shows
 WordPress doing any form of error handling if a hook does throw, so I'm
 weary about going this route as it would probably leave some of the
 globals in an unexpected state.

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


More information about the wp-trac mailing list