16

I'm working with the admin bar and trying to debug some of the menus and their priorities.

I know several callbacks get bound to actions, such as this one:

add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );

How can I see what is lined up to be called when a hook like admin_bar_menu is called?

  • Hook onto the shutdown action and print the $wp_filters global or similar? .. not got a working WP install right now to say in absolution... (but i know there's a global with filters and/or actions).. just a pointer.. ;) – t31os Nov 29 '11 at 22:56
  • awesome - just it needs to be singular $wp_filter – cwd Nov 30 '11 at 4:02
27

You can see the detailed list of the hook using this snippet:

$hook_name = 'admin_bar_menu';
global $wp_filter;
var_dump( $wp_filter[$hook_name] );
  • almost right. needs to be $wp_filter singular. thanks. – cwd Nov 30 '11 at 4:02
  • Right, answer updated. – Anh Tran Dec 1 '11 at 3:56
  • Is there an easy place that this can be placed so that it can be tested? I realize that this is pretty old, but anyone? – derickito Jan 31 '13 at 23:55
  • 1
    You can put it in header or footer, using wp_head, wp_footer or shutdown hook. Note: if you don't want users to see this debug information, you should check user permission by if ( current_user_can( 'manage_options' ) ) {...} – Anh Tran Feb 1 '13 at 2:03
  • I use some functions to format it more nicely. Useful if you use it often for debugging and want to see the info quicker. Here is a gist. – J.D. Jun 6 '14 at 15:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.