Display all hooks that run on your page

Add the following to your functions.php to display a sequential list of all actions that run on the page you’re viewing.

$debug_tags = array();
add_action( 'all', function ( $tag ) {
	global $debug_tags;
	if ( in_array( $tag, $debug_tags ) ) {
		return;
	}
	echo "<pre>" . $tag . "</pre>";
	$debug_tags[] = $tag;
} );

I find this a real life saver when tracing down bugs that are caused by/in actions/hooks.

That’s really all you need. Some blogposts are a lot shorter than others, but I guess that’s fine 🙂

Ps. I’m aware that I’m using an anonymous function which only works in PHP 5.3+ and a global what is really bad practice. This code snippet should only be used to trace down and solve a bug or do something else devy. Please remove this code afterwards, obviously don’t put this on production environments.

Related Posts

Powered By Related Posts for WordPress
Click Here to Learn More About Related Posts for WordPress

2 thoughts on “Display all hooks that run on your page

  1. Vey handy. Thank you!

  2. Hey, on occasion I get a 404 server error when I arrive at your website. I thought you may wish to know, regards

Leave a Reply

Your email address will not be published. Required fields are marked *