Make WordPress Core


Ignore:
Timestamp:
02/15/2023 11:35:33 PM (20 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.