Skip to content

Instantly share code, notes, and snippets.

@evanre
Last active October 24, 2022 18:44
Show Gist options
  • Save evanre/157b9519bc3668548102f35be8bb0161 to your computer and use it in GitHub Desktop.
Save evanre/157b9519bc3668548102f35be8bb0161 to your computer and use it in GitHub Desktop.
Just another WordPress debug function
/**
* Simple debug trace to the end of the page
*
* @usage d( $data );
*/
if ( true === WP_DEBUG ) {
function d( $data ) {
global $global_debug;
$global_debug[] = $data;
}
function d_core() {
global $global_debug;
ob_start();
print_r( $global_debug );
$dump = htmlspecialchars( ob_get_contents() );
ob_end_clean();
printf( '<pre><code>%s</code></pre>', $dump );
}
add_action( 'wp_footer', 'd_core', 100 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment