query-monitor
query-monitor copied to clipboard
Listen for hooks firing within set bounds
Implement hook discovery into QM (as discussed on Twitter).
Thinking something like the following:
do_action( 'qm/listen/start', 'label' );
...
do_action( 'foobar' );
...
$foo = apply_filters( 'bar', 0 );
...
do_action( 'qm/listen/stop', 'label' );
The above would result in display of both the foobar
action and the bar
filter in QM, with some display of the second parameter of the QM action hook (in this example, label
).
The purpose of label
would be to serve in identification when multiple bounds have been set.
As I see it, there are two approaches:
- Introduce a new QM collector and output
- Add feature to
hooks
collector and output
I'm personally favoring the second option, as it could introduce a pretty nice interface and contextualize the discovery. It's likely more work than option one, but ultimately I think a more cohesive experience.
With option two though, need to also consider that would add additional complexity to a relatively straight forward collector.
@johnbillion I may start on a PR for option one, but definitely interested in your thoughts before I get too far in.
Hmm, given that the Hooks panel can be filtered, I'm now thinking of a different option:
- Introduce a sub-panel
Submitted PR (#410).
Instead of a column for counting successive uses, I think I'll change to display like the Template Parts section:

Discovered Hooks sub-panel now looks like this:

Planning on adding additional info to the notice that shows when using the all
hook.
- [x] add line(s) of
do_action()
fire(s) to Label column as.qm-info.qm-supplemental
- [ ] add link to Discovered Hooks panel to
all
hook performance notice
Added trace info for the start and stop bounds, but I don't like how it displays:

Any suggestions?
I'm not satisfied with the current integration. Going to rebuild as a separate collector.
Rebuilt using separate collector and output. 😄
Man, forgot about this; so cool. 😂
Still so cool.