- Timestamp:
- 09/03/2020 11:57:12 PM (4 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/mu-plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins
-
Property
svn:ignore
set to
0-sandbox.php
-
Property
svn:ignore
set to
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/locales.php
r8347 r10237 12 12 namespace WordPressdotorg\Locales { 13 13 14 use GP_Locales ;14 use GP_Locales, GP_Locale; 15 15 16 16 /** … … 29 29 } 30 30 add_filter( 'get_available_languages', __NAMESPACE__ . '\set_available_languages', 10, 0 ); 31 32 /** 33 * Retrieves all available locales. 34 * 35 * @return GP_Locale[] Array of locale objects. 36 */ 37 function get_locales() { 38 wp_cache_add_global_groups( array( 'locale-associations' ) ); 39 40 $wp_locales = wp_cache_get( 'locale-list', 'locale-associations' ); 41 if ( false === $wp_locales ) { 42 $wp_locales = (array) $GLOBALS['wpdb']->get_col( 'SELECT locale FROM wporg_locales' ); 43 wp_cache_set( 'locale-list', $wp_locales, 'locale-associations' ); 44 } 45 46 $wp_locales[] = 'en_US'; 47 $locales = array(); 48 49 foreach ( $wp_locales as $locale ) { 50 $gp_locale = GP_Locales::by_field( 'wp_locale', $locale ); 51 if ( ! $gp_locale ) { 52 continue; 53 } 54 55 $locales[ $locale ] = $gp_locale; 56 } 57 58 natsort( $locales ); 59 60 return $locales; 61 } 62 63 /** 64 * Get an array of locales with the locale code as key and the native name as value. 65 * 66 * @return array 67 */ 68 function get_locales_with_native_names() { 69 $locales = get_locales(); 70 71 return wp_list_pluck( $locales, 'native_name', 'wp_locale' ); 72 } 73 74 /** 75 * Get an array of locales with the locale code as key and the English name as value. 76 * 77 * @return array 78 */ 79 function get_locales_with_english_names() { 80 $locales = get_locales(); 81 82 return wp_list_pluck( $locales, 'english_name', 'wp_locale' ); 83 } 31 84 }
Note: See TracChangeset
for help on using the changeset viewer.