Last active
October 24, 2022 18:44
-
-
Save evanre/157b9519bc3668548102f35be8bb0161 to your computer and use it in GitHub Desktop.
Just another WordPress debug function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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