Commit Graph

3 Commits

Author SHA1 Message Date
Gary Pendergast
d1b2a55b44 Plugins: Add a current_priority() method to WP_Hook.
This allows plugins to determine the currently running priority of a filter.

Fixes #39007.


Built from https://develop.svn.wordpress.org/trunk@39430


git-svn-id: http://core.svn.wordpress.org/trunk@39370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-02 07:10:43 +00:00
Drew Jaynes
f5db425059 Docs: Fix minor formatting for inline docs in WP_Hook following its introduction in [38571].
See #17817.

Built from https://develop.svn.wordpress.org/trunk@38573


git-svn-id: http://core.svn.wordpress.org/trunk@38516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-08 04:17:30 +00:00
Gary Pendergast
5a632be944 Hooks: Add the new class WP_Hook, and modify hook handling to make use of it.
Filters and actions have been the basis of WordPress' plugin functionality since time immemorial, they've always been a reliable method for acting upon the current state of WordPress, and will continue to be so.

Over the years, however, edge cases have cropped up. Particularly when it comes to recursively executing hooks, or a hook adding and removing itself, the existing implementation struggled to keep up with more complex use cases.

And so, we introduce `WP_Hook`. By changing `$wp_filter` from an array of arrays, to an array of objects, we reduce the complexity of the hook handling code, as the processing code (see `::apply_filters()`) only needs to be aware of itself, rather than the state of all hooks. At the same time, we're able te handle more complex use cases, as the object can more easily keep track of its own state than an array ever could.

Props jbrinley for the original architecture and design of this patch.
Props SergeyBiryukov, cheeserolls, Denis-de-Bernardy, leewillis77, wonderboymusic, nacin, jorbin, DrewAPicture, ocean90, dougwollison, khag7, pento, noplanman and aaroncampbell for their testing, suggestions, contributions, patch maintenance, cajoling and patience as we got through this.
Fixes #17817.


Built from https://develop.svn.wordpress.org/trunk@38571


git-svn-id: http://core.svn.wordpress.org/trunk@38514 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-08 03:55:31 +00:00