Make WordPress Core

Ticket #58484: patch.58484.20231019.6.diff

File patch.58484.20231019.6.diff, 4.0 KB (added by ramon fincken, 3 years ago)

patch.58484.20231019.6.diff

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

    diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php
    index d83c873768..0a623a6454 100644
    a b class WP_Debug_Data { 
    2020                wp_update_themes();
    2121        }
    2222
     23        /*
     24         * Helper function to determine the true value of a constant.
     25         *
     26         * @param string $constant_name The name of the constant to be checked.
     27         * @return string The actual value of the defined constant if it is defined as a true value
     28         *                If the constant is defined as empty, it will return "Defined as an empty string.".
     29         *                If the constant is as a false boolean it will return "Defined as boolean with value false."
     30         *                If the constant is as a true boolean it will return "Defined as boolean with value true."
     31         *                If the constant is as a true boolean it will return "Defined as boolean with value true."       
     32         *                If the constant is defined as NULL, it will return "Defined as NULL"
     33         *                If the constant is not defined at all, it will return "Undefined"     
     34        */
     35        private static function get_define_info( $constant_name ) {
     36                if ( ! defined( $constant_name ) ) {
     37                        return __( 'Undefined' );
     38                }
     39                       
     40                $value = constant( $constant_name );
     41                if ( $value === true ) {
     42                        // Translators: %s is always replaced with the PHP boolean named "true"
     43                        return sprintf( __ ( 'Defined as boolean with value %s.' ), 'true' );
     44                }
     45               
     46               
     47                if ( $value === false ) {
     48                        // Translators: %s is always replaced with the PHP boolean named "false"
     49                        return sprintf( __ ( 'Defined as boolean with value %s.' ), 'false' );
     50                }
     51                if ( $value === NULL ) {
     52                        // Translators: %s is always replaced with the PHP type named "NULL"
     53                        return sprintf( __ ( 'Defined as %s.' ), 'NULL' );
     54                }
     55                if ( $value === '' ) {
     56                        return __( 'Defined as an empty string.' );
     57                }
     58               
     59                return $value;
     60        }
     61
    2362        /**
    2463         * Static function for generating site debug data when required.
    2564         *
    class WP_Debug_Data { 
    236275                        $compress_css_debug = 'undefined';
    237276                }
    238277
    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 
    246278                $info['wp-constants'] = array(
    247279                        'label'       => __( 'WordPress Constants' ),
    248280                        'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
    class WP_Debug_Data { 
    254286                                ),
    255287                                'WP_HOME'             => array(
    256288                                        'label' => 'WP_HOME',
    257                                         'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
    258                                         'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
     289                                        'value' => self::get_define_info( 'WP_HOME' ),
     290                                        'debug' => self::get_define_info( 'WP_HOME' ),
    259291                                ),
    260292                                'WP_SITEURL'          => array(
    261293                                        'label' => 'WP_SITEURL',
    262                                         'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
    263                                         'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
     294                                        'value' => self::get_define_info( 'WP_SITEURL' ),
     295                                        'debug' => self::get_define_info( 'WP_SITEURL' ),
    264296                                ),
    265297                                'WP_CONTENT_DIR'      => array(
    266298                                        'label' => 'WP_CONTENT_DIR',
    class WP_Debug_Data { 
    330362                                ),
    331363                                'DB_CHARSET'          => array(
    332364                                        'label' => 'DB_CHARSET',
    333                                         'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
    334                                         'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
     365                                        'value' => self::get_define_info( 'DB_CHARSET' ),
     366                                        'debug' => self::get_define_info( 'DB_CHARSET' ),
    335367                                ),
    336368                                'DB_COLLATE'          => array(
    337369                                        'label' => 'DB_COLLATE',
    338                                         'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
    339                                         'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
     370                                        'value' => self::get_define_info( 'DB_COLLATE' ),
     371                                        'debug' => self::get_define_info( 'DB_COLLATE' ),
    340372                                ),
    341373                        ),
    342374                );