[wp-trac] [WordPress Trac] #46635: Improve identifying of non–trivial callbacks in hooks
WordPress Trac
noreply at wordpress.org
Mon Mar 25 09:41:35 UTC 2019
#46635: Improve identifying of non–trivial callbacks in hooks
-------------------------+-----------------------------
Reporter: Rarst | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
The API for hooks provides comprehensive support for adding any kind of
valid PHP callback.
However there are currently no easy way to identify non–trivial
(non–string) callbacks in any other operations, such as `has_*` or
`remove_*`.
Rather than discouraging use of complex callbacks, I would like to suggest
API is improved to better support them.
In my experience the best take I had seen is to identify complex callbacks
with a string representation in [https://brain-
wp.github.io/BrainMonkey/docs/wordpress-hooks-added.html Brain Monkey]
testing library.
Tentatively I would imagine support for following expressions (up for
discussion and refinement):
- `ClassName()` object instance (such as invokable object)
- `ClassName->foo()` concrete method callback
- `ClassName->*` any concrete method callback
- `class()` verbatim, anonymous class instance
- `function()` a closure instance
- `function( $argument )` a closure instance with specific signature
E.g. `remove_action( 'init', 'ClassName->*' )` should remove all method
callbacks belonging to instances of that class.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46635>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list