Advertisement
indikatordesign

Enable WP Error Log

Apr 4th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. ################################################################################################################
  2. #                                                                                                              #
  3. # Add the snippet below in the file wp-config.php right above: /* That's all, stop editing! Happy blogging. */ #
  4. # It will write the error.log right into the wp-content-folder.                                                #
  5. #                                                                                                              #
  6. # You can also use something like this to var_dump to your error log:                                          #
  7. # idWriteLog( $myVar, 'varName' );                                                                             #
  8. # idWriteLog( myFunc(), 'funcName' );                                                                          #
  9. #                                                                                                              #
  10. # it is especially useful to var_dump ajax requests                                                            #
  11. #                                                                                                              #
  12. ################################################################################################################
  13.  
  14. define('WP_DEBUG', true );
  15.  
  16. if ( WP_DEBUG )
  17. {
  18.  
  19.     // Save Queries inside database and that array can be displayed to help analyze
  20.     define('SAVEQUERIES', true );
  21.  
  22.     // Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
  23.     define('SCRIPT_DEBUG', true );
  24.  
  25.     // debug.log to wp-content
  26.     define( 'WP_DEBUG_LOG', true );
  27.     define( 'WP_DEBUG_DISPLAY', false );
  28.  
  29.     if ( ! function_exists( 'idWriteLog' ) )
  30.     {
  31.  
  32.         function idWriteLog( $log, $name = false )
  33.         {
  34.  
  35.  
  36.             $separator1 = '';
  37.  
  38.             for ( $i = 0; $i <= 53; $i++ ){ $separator1 .= '#'; }
  39.  
  40.             ob_start();
  41.  
  42.             echo '---***--- Custom var_dump: ---***---' . "\r\n\r\n";
  43.  
  44.             echo '### Start' . $separator1 . "\r\n\r\n";
  45.  
  46.             if ( function_exists( 'current_filter' ) )
  47.             {
  48.  
  49.                 echo 'Current Filter: ' . current_filter();
  50.  
  51.                 echo "\r\n\r\n";
  52.  
  53.             } // end if
  54.  
  55.             echo 'Output: ' . ( $name ? $name : '' );
  56.  
  57.             echo "\r\n\r\n";
  58.  
  59.             var_dump( $log );
  60.  
  61.             echo "\r\n";
  62.  
  63.             echo '### End  '. $separator1 . "\r\n\r\n";
  64.  
  65.             $result = ob_get_clean();
  66.  
  67.             error_log( $result );
  68.  
  69.         } // end idWriteLog
  70.     } // end if
  71. } // end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement