Gavin
Gavin

Reputation: 7976

Cannot test for value of WP_DEBUG constant in functions.php

I'm trying to check if WP_DEBUG is true but I'm experiencing some weird behavior. I made a barebones functions.php for testing:

<?php

define( 'WP_DEBUG', true );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) {
    die( 'WP_DEBUG' );
}

define( 'TEST', true );
if ( defined( 'TEST' ) && TEST === true ) {
    die( 'TEST' );
}

?>

This script always dies with TEST. The WP_DEBUG condition never returns true. Any idea what's causing this weird behavior?

Upvotes: 1

Views: 68

Answers (1)

Vel
Vel

Reputation: 9342

define( 'WP_DEBUG', true ); already defined in wp_config.php file. You dont need to define again. Remove this code define( 'WP_DEBUG', true ); from functions.php.

and add this code functions.php.

if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) {
    die( 'WP_DEBUG' );
}

Upvotes: 2

Related Questions