Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper functions for developing and debugging WordPress plugins and themes
/**
* Prints all actions and filters hooked to a given hook.
*
* Prints all actions and filters hooked to a given hook.
* Inspired by answers in this WordPress Stackexchange question: https://wordpress.stackexchange.com/questions/17394/how-to-know-what-functions-are-hooked-to-an-action-filter
*/
function what_is_hooked(){
$hook_name = current_filter();
global $wp_filter;
echo '<pre>';
print_r( $wp_filter[$hook_name], true );
echo '</pre>';
}
// Now you add it to the hook you want to check. e.g. wp_head
add_action( 'wp_head', 'what_is_hooked', 999);
/**
* Logs all actions and filters hooked to a given hook.
*
* Logs all actions and filters hooked to a given hook.
* Inspired by answers in this WordPress Stackexchange question: https://wordpress.stackexchange.com/questions/17394/how-to-know-what-functions-are-hooked-to-an-action-filter
*/
function log_what_is_hooked(){
$hook_name = current_filter();
global $wp_filter;
error_log( print_r( $wp_filter[$hook_name], true ) );
}
// Now you add it to the hook you want to check. e.g. wp_head
add_action( 'wp_head', 'log_what_is_hooked', 999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.