Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php
- Timestamp:
- 12/19/2017 04:22:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php
r6196 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 4 5 use WP_REST_Server; … … 15 16 'methods' => WP_REST_Server::EDITABLE, 16 17 'callback' => array( $this, 'locale_banner' ), 17 'args' => array(18 'args' => array( 18 19 'plugin_slug' => array( 19 20 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), … … 69 70 70 71 // Build a list of WordPress locales which we'll suggest to the user. 71 $suggest_locales = array_values( array_intersect( $locales_from_header, $translated_locales ) );72 $current_locale_is_suggested = in_array( $current_locale, $suggest_locales );72 $suggest_locales = array_values( array_intersect( $locales_from_header, $translated_locales ) ); 73 $current_locale_is_suggested = in_array( $current_locale, $suggest_locales ); 73 74 $current_locale_is_translated = in_array( $current_locale, $translated_locales ); 74 75 … … 116 117 } 117 118 118 // Multiple locale suggestions.119 // Multiple locale suggestions. 119 120 } elseif ( ! empty( $suggest_named_locales ) ) { 120 $primary_locale = key( $suggest_named_locales );121 $primary_locale = key( $suggest_named_locales ); 121 122 $primary_language = current( $suggest_named_locales ); 122 123 array_shift( $suggest_named_locales ); … … 169 170 } 170 171 171 // Non-English locale in header, no translations.172 // Non-English locale in header, no translations. 172 173 } elseif ( $locales_from_header ) { 173 174 $locale = reset( $locales_from_header ); … … 180 181 } 181 182 182 // Localized directory.183 // Localized directory. 183 184 } elseif ( ! $current_locale_is_suggested && ! $current_locale_is_translated && $is_plugin_request ) { 184 185 $suggest_string = sprintf( … … 254 255 protected function get_http_locales( $header ) { 255 256 $locale_part_re = '[a-z]{2,}'; 256 $locale_re = "($locale_part_re(\-$locale_part_re)?)"; 257 $locale_re = "($locale_part_re(\-$locale_part_re)?)"; 258 257 259 if ( preg_match_all( "/$locale_re/i", $header, $matches ) ) { 258 260 return $matches[0]; … … 271 273 */ 272 274 protected function map_locale( $lang, $region, $available_locales ) { 273 $uregion = strtoupper( $region );274 $ulang = strtoupper( $lang );275 $uregion = strtoupper( $region ); 276 $ulang = strtoupper( $lang ); 275 277 $variants = array( 276 278 "$lang-$region", … … 353 355 354 356 // Strings for the POT file. 355 356 357 /* translators: %s: native language name. */ 357 358 __( 'This plugin is also available in %1$s. <a href="%2$s">Help improve the translation!</a>', 'wporg-plugins' );
Note: See TracChangeset
for help on using the changeset viewer.