Skip to content

Instantly share code, notes, and snippets.

@indikatordesign
Last active October 27, 2017 13:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save indikatordesign/946c2044cb4c74dd01eb3126bc1371f8 to your computer and use it in GitHub Desktop.
Save indikatordesign/946c2044cb4c74dd01eb3126bc1371f8 to your computer and use it in GitHub Desktop.
[WordPress Debug.log and useful var_dump snippet]Allows you to write the error.log right into the wp-content-folder. You can also use something like this to var_dump to your error log: - idWriteLog( $myVar, 'varName' ); - or - idWriteLog( myFunc(), 'funcName' ); - It is especially useful to var_dump ajax requests and will also show you on which …
<?php
// Add the snippet below in the file wp-config.php right above: /* That's all, stop editing! Happy blogging. */
define('WP_DEBUG', true );
if ( WP_DEBUG )
{
define('SAVEQUERIES', true );
define('SCRIPT_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
if ( ! function_exists( 'idWriteLog' ) )
{
function idWriteLog( $log, $name = false )
{
$separator1 = '';
for ( $i = 0; $i <= 53; $i++ ){ $separator1 .= '#'; }
ob_start();
echo '---***--- Custom var_dump: ---***---' . "\r\n\r\n";
echo '### Start' . $separator1 . "\r\n\r\n";
if ( function_exists( 'current_filter' ) )
{
echo 'Current Filter: ' . current_filter();
echo "\r\n\r\n";
} // end if
echo 'Output: ' . ( $name ? $name : '' );
echo "\r\n\r\n";
var_dump( $log );
echo "\r\n";
echo '### End '. $separator1 . "\r\n\r\n";
$result = ob_get_clean();
error_log( $result );
} // end idWriteLog
} // end if
} // end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment