You can use error_log()
and print_r()
:
add_action( 'wp_footer', 'wpse_debug_toolbar' );
function wpse_debug_toolbar() {
global $wp_admin_bar;
error_log( print_r( $wp_admin_bar, true ) );
}
Note that when using print_r()
we’ve set the second parameter $return
to true
so that the results are returned and not echo’d.