Created
June 10, 2019 13:37
-
-
Save addzycullen/b7f59d14960686217289d5c9a1812801 to your computer and use it in GitHub Desktop.
This fn allows you write to the WordPress debug log if you have it enabled in the wp_config file.
This file contains 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
/** | |
* Write to Debug Log | |
* | |
* Add to your functions.php file for use in a theme. | |
* Remember to remove from live environment. | |
* | |
* @param object $log | |
* @return void | |
*/ | |
if (!function_exists('write_log')) { | |
function write_log($log) { | |
if (is_array($log) || is_object($log)) { | |
error_log(print_r($log, true)) | |
} else { | |
error_log($log) | |
} | |
} | |
} | |
// Examples Below | |
// Use in any php file to see if line ever gets called. | |
write_log( __LINE__ ); | |
// Or to check if a var is what it's suppose to be. | |
write_log( $my_post ); | |
// Or to log information. | |
write_log( "The following post {$my_post} was written by {$author_id}" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment