Skip to content

Dump variables and traces in an organized and interactive display. Integrates seamlessly with Debug Bar.

License

Notifications You must be signed in to change notification settings

jameelmoses/wordpress-kint-debugger

Repository files navigation

WordPress Kint Debugger

Dump variables and traces in an organized and interactive display. Integrates seamlessly with Debug Bar.

Description

WordPress Kint Debugger is a simple wrapper for Kint, a debugging tool to output information about variables and traces in a styled, collapsible format that makes understanding deep arrays and objects easier.

No more adding PRE tags before print_r or var_dump!

Kint Debugger works well with the Debug Bar plugin by creating its own panel to display your debug results.

Basic Usage

ddb( $var );

Examples:

global $post;
ddb( $post );
global $post;
$term_list = wp_get_post_terms( $post->ID, 'my_taxonomy', array( 'fields' => 'all' ) );
ddb( $term_list );

Kint Debugger also provides some helper functions for dumping variables that are frequently needed.

  • dump_wp_query()
  • dump_wp()
  • dump_post()

Examples:

dump_post();
add_action( 'wp_head', 'dump_post' );

Obviously, if this plugin is not active, calls to these functions will cause errors.

Your Own Functions

If you are dumping the same information in different places, consider writing your own helper functions in your theme's functions file or an mu-plugin. For example:

function my_dump_terms() {
  global $post;
  $term_list = wp_get_post_terms( $post->ID, 'my_taxonomy', array( 'fields' => 'all' ) );
  ddb( $term_list  );
}

Then at strategic points in your theme or plugin:

my_dump_terms();

With Debug Bar

When Debug Bar is installed and active, Kint Debugger will send ddb() output to its Debug Bar panel.

To print a specific dump inline, use Kint's native d() call:

d( $var );

Helper functions take a boolean parameter $inline. Examples:

dump_post( true );
dump_wp( true );

Restricting Output

To restrict visibility, use the kint_debug_display filter. For example, to prevent non-admins from seeing the debug output:

add_filter( 'kint_debug_display', function( $allow ) { return is_super_admin(); } );

Frequently Asked Questions

I have called a debug function, but I can't find the output.

If Debug Bar is installed and active, your debug results when calling ddb will be displayed on the "Kint Debugger" panel.

Otherwise, your debug results will be inserted into the current page's HTML.

Can I change the style of the output?

See Kint library documentation. This plugin does not theme the output, nor should it prevent Kint's theming options from being used.


Credit

Credit goes to Brian Fegter and Chris Dillon for their plugin. This was created from a fork since the old plugin was no longer being maintained, and offers to adopt weren't responded to.

About

Dump variables and traces in an organized and interactive display. Integrates seamlessly with Debug Bar.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages