Make WordPress Core

Ticket #58484: patch.58484.20231019.7.diff

File patch.58484.20231019.7.diff, 3.9 KB (added by ramon fincken, 3 years ago)

patch.58484.20231019.7.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..2873ca4a4a 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         * @since 6.5.0
     27         *
     28         * @param string $constant_name The name of the constant to be checked.
     29         * @return string If the constant is not defined at all, it will return "Undefined"     
     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 false boolean it will return "Defined as boolean with value false."
     32         *                If the constant is defined as NULL, it will return "Defined as NULL"
     33         *                If the constant is defined as empty, it will return "Defined as an empty string.".
     34         *                Otherwise it is the value as defined.
     35        */
     36        private static function get_define_info( $constant_name ) {
     37                if ( ! defined( $constant_name ) ) {
     38                        return __( 'Undefined' );
     39                }
     40                       
     41                $value = constant( $constant_name );
     42               
     43                if ( true === $value ) {
     44                        // Translators: %s is always replaced with the PHP boolean named "true"
     45                        return sprintf( __ ( 'Defined as boolean with value %s.' ), 'true' );
     46                }
     47               
     48               
     49                if ( false === $value ) {
     50                        // Translators: %s is always replaced with the PHP boolean named "false"
     51                        return sprintf( __ ( 'Defined as boolean with value %s.' ), 'false' );
     52                }
     53                if ( NULL === $value ) {
     54                        // Translators: %s is always replaced with the PHP type named "NULL"
     55                        return sprintf( __ ( 'Defined as %s.' ), 'NULL' );
     56                }
     57                if ( '' === $value ) {
     58                        return __( 'Defined as an empty string.' );
     59                }
     60               
     61                return $value;
     62        }
     63
    2364        /**
    2465         * Static function for generating site debug data when required.
    2566         *
    class WP_Debug_Data { 
    236277                        $compress_css_debug = 'undefined';
    237278                }
    238279
    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 
    246280                $info['wp-constants'] = array(
    247281                        'label'       => __( 'WordPress Constants' ),
    248282                        'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
    class WP_Debug_Data { 
    254288                                ),
    255289                                'WP_HOME'             => array(
    256290                                        'label' => 'WP_HOME',
    257                                         'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
    258                                         'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
     291                                        'value' => self::get_define_info( 'WP_HOME' ),
     292                                        'debug' => self::get_define_info( 'WP_HOME' ),
    259293                                ),
    260294                                'WP_SITEURL'          => array(
    261295                                        'label' => 'WP_SITEURL',
    262                                         'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
    263                                         'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
     296                                        'value' => self::get_define_info( 'WP_SITEURL' ),
     297                                        'debug' => self::get_define_info( 'WP_SITEURL' ),
    264298                                ),
    265299                                'WP_CONTENT_DIR'      => array(
    266300                                        'label' => 'WP_CONTENT_DIR',
    class WP_Debug_Data { 
    330364                                ),
    331365                                'DB_CHARSET'          => array(
    332366                                        'label' => 'DB_CHARSET',
    333                                         'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
    334                                         'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
     367                                        'value' => self::get_define_info( 'DB_CHARSET' ),
     368                                        'debug' => self::get_define_info( 'DB_CHARSET' ),
    335369                                ),
    336370                                'DB_COLLATE'          => array(
    337371                                        'label' => 'DB_COLLATE',
    338                                         'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
    339                                         'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
     372                                        'value' => self::get_define_info( 'DB_COLLATE' ),
     373                                        'debug' => self::get_define_info( 'DB_COLLATE' ),
    340374                                ),
    341375                        ),
    342376                );