What is the nice and easy way to see all the hooks that run in WordPress during a page load? How do you see them sequentially when things/contents are being loaded? WordPress has a special hook named all
which runs for every single hook.
From WordPress doc:
If you want a callback function to fire on every single hook, you can register it to the all hook. Sometimes this is useful in debugging situations to help determine when a particular event is happening or when a page is crashing.
We are going to utilize this hook and print out all action/filter hooks that are being called for the current page.
$loaded_hooks = array();
function careless_display_current_hooks( $tag ) {
global $loaded_hooks;
if ( in_array( $tag, $loaded_hooks ) ) {
return;
}
echo "<pre>" . $tag . "</pre>";
$loaded_hooks[] = $tag;
}
add_action( 'all', 'careless_display_current_hooks' );
Now visit any page and you will see all the hooks that were called for that particular page, with a nice visual representation along side the content.
Code goes in the functions.php
file of your active theme.