Index of /andrejciho/WordPress/Debugging a live WordPress site using WP_DEBUG

Post Title Posted Description
Back Parent Directory
Debugging a live WordPress site using WP_DEBUG 2012-01-26 20:39

Enable WP_DEBUG messages just for YOU, but nobody else


Be Sociable, Share!

WP_DEBUG is a boolean constant found in wp-config.php. When set to true, all php errors (and warnings and notifications) are printed in the browser. This is very useful during development but can be dangerous because text of php errors often reveals unnecessary details about your programming code, paths, etc to visitors in case they run into an issue with your site. For production sites this is always set to false.

But what do you do when you get a frantic client phone call reporting an issue on the live site? You can’t just enable WP_DEBUG for everybody and very likely break the site’s design as various error messages of sloppy plugin or WordPress’ core code might render.

Solution is simple: Enable WP_DEBUG just for you.

First, you’ll need to know your outgoing IP address. When I’m lazy I go to my friend Topher’s beautiful website which tells me my IP address.

Then edit your wp-config.php (CAREFUL) by replacing:

PHP
1
define('WP_DEBUG', false);

with

PHP
1
2
3
4
5
if ($_SERVER['REMOTE_ADDR'] == '123.123.123.123') {
    define('WP_DEBUG', true);    
} else {
    define('WP_DEBUG', false);
}

(don’t forget to replace 123.123.123.123 with your outgoing IP address)

By the way this is a great solution if you’re working from home or are tethering using your phone so that you are the only one coming from this IP address. If you’re in the same building with your client and try to debug the site without freaking out the CEO this might not be the best because odds are you and her are coming from the same IP address and she’ll see the same debug junk you do.

Please let me know if this was any helpful to you.


Leave a Comment
*Required
*Required (Never published)
 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

This website is powered by Wordpress