Skip to content

Instantly share code, notes, and snippets.

@butlerblog
Last active November 24, 2022 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save butlerblog/b2919d61c0402269b0802117c511c387 to your computer and use it in GitHub Desktop.
Save butlerblog/b2919d61c0402269b0802117c511c387 to your computer and use it in GitHub Desktop.
#utility for finding callback functions hooked to a specific hook
<?php // do not use this line. Add below to functions.php
add_action( 'wp_footer', 'list_hooked_filters_and_actions' );
add_action( 'login_footer', 'list_hooked_filters_and_actions' );
add_action( 'admin_footer', 'list_hooked_filters_and_actions' );
function list_hooked_filters_and_actions() {
global $wp_filter;
$hook = 'login_form';
if( empty( $hook ) || !isset( $wp_filter[$hook] ) )
return;
echo '<div style="background-color:#D3D3D3;min-height:200px;">';
echo '<h2>Callbacks hooked to "' . $hook . '"</h2><ul>';
foreach( $wp_filter[ $hook ]->callbacks as $key => $priority ) {
foreach ( $priority as $callback => $details ) {
echo '<li>' . $details['function'] . ' priority: ' . $key . '</li>';
}
}
echo '</ul></div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment