You should not change the output you want to debug just to debug it, that’s a contradiction. 🙂
Use cookies for that. For example, put something like this into your wp-config.php
:
if ( ! empty ( $_GET['debug'] ) )
{
if ( 'on' === $_GET['debug'] )
set_debug_mode( TRUE );
elseif ( 'off' === $_GET['debug'] )
set_debug_mode( FALSE );
}
elseif ( isset ( $_COOKIE['debug'] ) )
{
if ( 'on' === $_COOKIE['debug'] )
set_debug_mode( TRUE );
else
set_debug_mode( FALSE );
}
else
{
set_debug_mode( FALSE );
}
/**
* Turn debug mode on or off.
*
* @param bool $on
* @return bool TRUE if cookie could be set.
*/
function set_debug_mode( $on = TRUE )
{
if ( ! $on )
return setcookie( 'debug', 'on', time() - 3600, "https://wordpress.stackexchange.com/" );
define( 'WP_DEBUG', TRUE );
define( 'WP_DEBUG_DISPLAY', TRUE );
define( 'SAVEQUERIES', TRUE );
define( 'DIEONDBERROR', TRUE );
define( 'SCRIPT_DEBUG', TRUE );
return setcookie( 'debug', 'on', time() + 604800, "https://wordpress.stackexchange.com/" ); // one week;
}
Now add ?debug=on
to any URL, and all following requests will use the debug mode. Add ?debug=off
to delete the cookie and to turn debug mode off.