Make WordPress Core

Ticket #58484: patch.58484.20230608.3.diff

File patch.58484.20230608.3.diff, 3.0 KB (added by ramon fincken, 3 years ago)

patch.58484.20230608.3.diff

  • wp-admin/includes/class-wp-debug-data.php

     
    2020                wp_update_themes();
    2121        }
    2222
     23        /*
     24        * Returns the value of a defined constant. If the constant is defined as empty, it will return "Defined as empty".
     25        * If the constant is not defined, it will return "Undefined"
     26        */
     27        private static function get_define_info( $constant_name ) {
     28                // Check WP_ENVIRONMENT_TYPE.
     29                if ( defined( $constant_name ) ) {
     30                        $value = constant( $constant_name );
     31                        if( !$value ) {
     32                                $value = __( 'Defined as empty' );
     33                        }
     34                } else {
     35                        $value = __( 'Undefined' );
     36                }
     37                return $value;
     38        }
     39
    2340        /**
    2441         * Static function for generating site debug data when required.
    2542         *
     
    236253                        $compress_css_debug = 'undefined';
    237254                }
    238255
    239                 // Check WP_ENVIRONMENT_TYPE.
    240                 if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
    241                         $wp_environment_type = WP_ENVIRONMENT_TYPE;
    242                 } else {
    243                         $wp_environment_type = __( 'Undefined' );
    244                 }
    245 
    246256                $info['wp-constants'] = array(
    247257                        'label'       => __( 'WordPress Constants' ),
    248258                        'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
     
    254264                                ),
    255265                                'WP_HOME'             => array(
    256266                                        'label' => 'WP_HOME',
    257                                         'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
    258                                         'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
     267                                        'value' => self::get_define_info( 'WP_HOME' ),
     268                                        'debug' => self::get_define_info( 'WP_HOME' ),
    259269                                ),
    260270                                'WP_SITEURL'          => array(
    261271                                        'label' => 'WP_SITEURL',
    262                                         'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
    263                                         'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
     272                                        'value' => self::get_define_info( 'WP_SITEURL' ),
     273                                        'debug' => self::get_define_info( 'WP_SITEURL' ),
    264274                                ),
    265275                                'WP_CONTENT_DIR'      => array(
    266276                                        'label' => 'WP_CONTENT_DIR',
     
    320330                                ),
    321331                                'WP_ENVIRONMENT_TYPE' => array(
    322332                                        'label' => 'WP_ENVIRONMENT_TYPE',
    323                                         'value' => $wp_environment_type,
    324                                         'debug' => $wp_environment_type,
     333                                        'value' => self::get_define_info( 'WP_ENVIRONMENT_TYPE' ),
     334                                        'debug' => self::get_define_info( 'WP_ENVIRONMENT_TYPE' ),
    325335                                ),
    326336                                'DB_CHARSET'          => array(
    327337                                        'label' => 'DB_CHARSET',
    328                                         'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
    329                                         'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
     338                                        'value' => self::get_define_info( 'DB_CHARSET' ),
     339                                        'debug' => self::get_define_info( 'DB_CHARSET' ),
    330340                                ),
    331341                                'DB_COLLATE'          => array(
    332342                                        'label' => 'DB_COLLATE',
    333                                         'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
    334                                         'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
     343                                        'value' => self::get_define_info( 'DB_COLLATE' ),
     344                                        'debug' => self::get_define_info( 'DB_COLLATE' ),
    335345                                ),
    336346                        ),
    337347                );