WordPress.org

Making WordPress.org

Changeset 7124


Ignore:
Timestamp:
04/18/2018 08:27:13 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: Locale Banner: Validate that the Locales can be found by wp_locale before attempting to use them.

See #3581.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php

    r6340 r7124  
    6969        $current_locale = get_locale();
    7070
     71        require_once GLOTPRESS_LOCALES_PATH;
     72
     73        // Validate the list of locales can be found by `wp_locale`.
     74        $translated_locales = array_filter( $translated_locales, function( $locale ) {
     75            return \GP_Locales::by_field( 'wp_locale', $locale );
     76        } );
     77
    7178        // Build a list of WordPress locales which we'll suggest to the user.
    7279        $suggest_locales              = array_values( array_intersect( $locales_from_header, $translated_locales ) );
    7380        $current_locale_is_suggested  = in_array( $current_locale, $suggest_locales );
    7481        $current_locale_is_translated = in_array( $current_locale, $translated_locales );
    75 
    76         require_once GLOTPRESS_LOCALES_PATH;
    7782
    7883        // Get the native language names of the locales.
Note: See TracChangeset for help on using the changeset viewer.