title

List All Hooked Functions

 

List All Hooked Functions

23 Oct 2013, Posted by antoine in

I started writing a function to do this. When I did a quick Google search, it turned out that WP Recipes had exactly what I needed.

function list_hooked_functions($tag=false){
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}
}
else {
$hook=$wp_filter;
ksort($hook);
}
echo '
';
foreach($hook as $tag => $priority){
echo "
>>>>>\t$tag
";
ksort($priority);
foreach($priority as $priority => $function){
echo $priority;
foreach($function as $name => $properties) {
echo "\t$name
";
}
}
}
echo '
';
return;
}

Used without an argument, you’ll get a nice list of all hooked functions. This will be a bit long, so you can specify a hook to narrow the list a bit. This is particularly useful when debugging or fiddling around with hook priorities. Knowing what’s hooked into wp_head() in what order is important, and this function is a great asset!