Last active
October 9, 2024 00:29
-
-
Save aydinjavadly/d40c2132c950ab191fbd4260403223d6 to your computer and use it in GitHub Desktop.
WordPress - Enable WP_DEBUG only for specific IP address.
This file contains hidden or 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
<?php | |
/** | |
* File: wp-config.php | |
* | |
* Enable WordPress debug only for your IP address | |
* | |
* Once you know your IP address you can edit your wp-config.php file and edit the WP_DEBUG constant and replace it with this function and your IP address. | |
* | |
* NOTE: If you re-boot your router and have a dynamic IP address you will need to update your IP address in wp-config.php | |
*/ | |
// 1. by REMOTE_ADDR (recommended) | |
if ( !empty($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '00.00.00.00' ) { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'WP_DEBUG_DISPLAY', true ); | |
} else { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false ); | |
define( 'WP_DEBUG', false ); | |
define( 'WP_DEBUG_LOG', false ); | |
define( 'WP_DEBUG_DISPLAY', false ); | |
} | |
// 2. by HTTP_X_REAL_IP | |
if ( !empty($_SERVER['HTTP_X_REAL_IP']) && $_SERVER['HTTP_X_REAL_IP'] == '00.00.00.00' ) { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'WP_DEBUG_DISPLAY', true ); | |
} else { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false ); | |
define( 'WP_DEBUG', false ); | |
define( 'WP_DEBUG_LOG', false ); | |
define( 'WP_DEBUG_DISPLAY', false ); | |
} | |
// 3. by HTTP_CLIENT_IP | |
if ( !empty($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] == '00.00.00.00' ) { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'WP_DEBUG_DISPLAY', true ); | |
} else { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false ); | |
define( 'WP_DEBUG', false ); | |
define( 'WP_DEBUG_LOG', false ); | |
define( 'WP_DEBUG_DISPLAY', false ); | |
} | |
// 4. by HTTP_X_FORWARDED_FOR | |
if ( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] == '00.00.00.00' ) { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'WP_DEBUG_DISPLAY', true ); | |
} else { | |
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false ); | |
define( 'WP_DEBUG', false ); | |
define( 'WP_DEBUG_LOG', false ); | |
define( 'WP_DEBUG_DISPLAY', false ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment