Enable Error Debugging And Logging To Use On Live Sites
This is a piece of code I wrote to make use of the WP_DEBUG constants that are normally disabled by default. Well, I created a way to not only enable WP_DEBUG so you can use it on a live site with no negative side-effects, but I also made use of the other debugging constants for forcing errors to be displayed, and for creating a log file of the errors and Notices in the /wp-content directory.
Drop this code in your wp-config.php file ( AFTERAFTER YOU SAVE A BACKUP JUST IN CASE ) and then you can pass the ?debug=1, 2, or 3 parameters at the end of any urlURL on your site.
?debug=1 = shows all errors/notices ?debug=2 = forces them to be displayed ?debug=3 = creates a debug.log file of all errors in /wp-content dir.
/** * Written by Jared Williams - http://new2wp.com * @wp-config.php replace WP_DEBUG constant with this code * Enable WP debugging for usage on a live site * http://core.trac.wordpress.org/browser/trunk/wp-includes/load.php#L230 * Pass the '?debug=#' parameter at the end of any urlURL on site * * http://example.com/?debug=1, /?debug=2, /?debug=3 */ if ( isset($_GET['debug']) && $_GET['debug'] == '1' ) { // enableEnable the reporting of notices during development - E_ALL define('WP_DEBUG', true); } elseif ( isset($_GET['debug']) && $_GET['debug'] == '2' ) { // mustMust be true for WP_DEBUG_DISPLAY to work define('WP_DEBUG', true); // forceForce the display of errors define('WP_DEBUG_DISPLAY', true); } elseif ( isset($_GET['debug']) && $_GET['debug'] == '3' ) { // mustMust be true for WP_DEBUG_LOG to work define('WP_DEBUG', true); // logLog errors to debug.log in the wp-content directory define('WP_DEBUG_LOG', true); } I go into more detail on the guest post I wrote for Comluv if you're interested, here: http://comluv.com/dev/enable-debugging-and-logging-for-live-site-usage/
I'm still working on a way to make this either password protected, or preferrably somehow make it work on if (current_user_can('manage_themes') and is_logged_in().
But that's where it gets alot more tricky.