Last active
September 5, 2018 03:09
-
-
Save kingkool68/f3182a16f57e0242fa36a4d0620172dd to your computer and use it in GitHub Desktop.
A better dumping function that preservers whitespace making things easier to read.
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
<?php | |
if ( ! function_exists( 'wp_dump' ) ) : | |
/** | |
* Dump variables preserving whitespace so they are easier to read. | |
*/ | |
function wp_dump() { | |
$is_xdebug = false; | |
if ( function_exists( 'xdebug_dump_superglobals' ) ) { | |
$is_xdebug = true; | |
} | |
foreach ( func_get_args() as $arg ) { | |
// If xdebug is installed let it do it's own thing... | |
if ( $is_xdebug ) { | |
var_dump( $arg ); | |
continue; | |
} | |
echo '<xmp>'; | |
var_dump( $arg ); | |
echo '</xmp>'; | |
} | |
} | |
endif; |
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
<?php | |
if ( ! function_exists( 'wp_log' ) ) : | |
/** | |
* A better error_log() function | |
*/ | |
function wp_log() { | |
foreach ( func_get_args() as $arg ) { | |
if ( is_array( $arg ) || is_object( $arg ) ) { | |
error_log( print_r( $arg, true ) ); | |
} else { | |
error_log( $arg ); | |
} | |
} | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment