Make WordPress Core

Changeset 45110


Ignore:
Timestamp:
04/04/2019 09:23:29 PM (8 years ago)
Author:
desrosj
Message:

Site Health: Ensure the user locale is listed in debug information.

This change switches to using get_user_locale() when adding the language to the Site Health debug information to ensure the user’s locale preference is reflected.

Also, function_exists() checks for switch_to_locale() and restore_previous_locale() were required in the plugin to support older versions of WordPress, but they are not required in core/

Props: Clorith, desrosj.
Fixes #46694.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r45108 r45110  
    3535                if ( ! empty( $locale ) ) {
    3636                        // Change the language used for translations
    37                         if ( function_exists( 'switch_to_locale' ) ) {
    38                                 $original_locale = get_locale();
    39                                 $switched_locale = switch_to_locale( $locale );
    40                         }
     37                        $original_locale = get_user_locale();
     38                        $switched_locale = switch_to_locale( $locale );
    4139                }
    4240
    … …  
    7472                                        'language'               => array(
    7573                                                'label' => __( 'Language' ),
    76                                                 'value' => ( ! empty( $locale ) ? $original_locale : get_locale() ),
     74                                                'value' => ( ! empty( $locale ) ? $original_locale : get_user_locale() ),
    7775                                        ),
    7876                                        'home_url'               => array(
    … …  
    889887                if ( ! empty( $locale ) ) {
    890888                        // Change the language used for translations
    891                         if ( function_exists( 'restore_previous_locale' ) && $switched_locale ) {
     889                        if ( $switched_locale ) {
    892890                                restore_previous_locale();
    893891                        }
  • trunk/src/wp-admin/site-health-info.php

    r45099 r45110  
    6969        $info         = WP_Debug_Data::debug_data();
    7070        $english_info = '';
    71         if ( 0 !== strpos( get_locale(), 'en' ) ) {
     71        if ( 0 !== strpos( get_user_locale(), 'en' ) ) {
    7272                $english_info = WP_Debug_Data::debug_data( 'en_US' );
    7373        }
Note: See TracChangeset for help on using the changeset viewer.