Make WordPress Core

Changeset 55351


Ignore:
Timestamp:
02/15/2023 11:35:33 PM (16 months ago)
Author:
SergeyBiryukov
Message:

I18N: Check that $wp_locale global is set before calling its methods.

This avoids a fatal error if these functions are called in a mu-plugin before $wp_locale is set:

  • wp_get_list_item_separator()
  • wp_get_word_count_type()

Follow-up to [52929], [52933], [55279], [55295].

Props kraftbj.
Fixes #56698.

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-locale.php

    r55295 r55351  
    236236        $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point;
    237237
    238         /* translators: used between list items, there is a space after the comma */
     238        /* translators: Used between list items, there is a space after the comma. */
    239239        $this->list_item_separator = __( ', ' );
    240240
  • trunk/src/wp-includes/l10n.php

    r55295 r55351  
    18081808    global $wp_locale;
    18091809
     1810    if ( ! ( $wp_locale instanceof WP_Locale ) ) {
     1811        // Default value of WP_Locale::get_list_item_separator().
     1812        /* translators: Used between list items, there is a space after the comma. */
     1813        return __( ', ' );
     1814    }
     1815
    18101816    return $wp_locale->get_list_item_separator();
    18111817}
     
    18241830    global $wp_locale;
    18251831
     1832    if ( ! ( $wp_locale instanceof WP_Locale ) ) {
     1833        // Default value of WP_Locale::get_word_count_type().
     1834        return 'words';
     1835    }
     1836
    18261837    return $wp_locale->get_word_count_type();
    18271838}
Note: See TracChangeset for help on using the changeset viewer.