Debug your custom code
One thing is to do quality checks, but if you wite your code in a certain way, it can check itself.
In your wp-config
define('WP_DEBUG_DISPLAY', false); define( 'WP_DEBUG_LOG', true ); define('WP_DEBUG', true);
debug mode is on but not shown in site, they are logged to a file
A helper function to log
function bcxcxvbcbvfdDebug($trace, $message = '') { $file = $trace[0]['file']; $function = $trace[0]['function']; $line = $trace[0]['line']; error_log( 'function: ' . $function . '() in ' . $file . ' on line ' . $line ); if (!empty($message)) { error_log($function . '(): ' . $message); } }
Usage
function test_debug_function($value) { if ($value != 'checked') { bcxcxvbcbvfdDebug(debug_backtrace(), 'Value: ' . $value); } } test_debug_function('not-checked');
Results
[14-Apr-2018 15:34:37 UTC] function: test_debug_function() in /home/lekker/public_html/content/themes/lekker-kontje/functions.php on line 313 [14-Apr-2018 15:34:37 UTC] test_debug_function(): Value: not-checked
Other posts: