Ticket #29395: 29395.3.patch
File 29395.3.patch, 9.7 KB (added by , 10 years ago) |
---|
-
src/wp-admin/css/forms.css
611 611 font-size: 13px; 612 612 } 613 613 614 table.form-table td .updated p { 615 font-size: 13px; 616 margin: 0.3em 0; 614 table.form-table td .updated p { 615 font-size: 13px; 616 margin: 0.3em 0; 617 617 } 618 618 619 619 /*------------------------------------------------------------------------------ … … 767 767 margin: -3px 3px; 768 768 } 769 769 770 .settings-php .language-install-spinner, 771 .options-general-php .language-install-spinner { 772 display: inline-block; 773 float: none; 774 margin: -3px 5px 0; 775 vertical-align: middle; 776 } 777 770 778 /* =Media Queries 771 779 -------------------------------------------------------------- */ 772 780 -
src/wp-admin/network/settings.php
10 10 /** Load WordPress Administration Bootstrap */ 11 11 require_once( dirname( __FILE__ ) . '/admin.php' ); 12 12 13 /** WordPress Translation Install API */ 14 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 15 13 16 if ( ! is_multisite() ) 14 17 wp_die( __( 'Multisite support is not enabled.' ) ); 15 18 … … 19 22 $title = __( 'Network Settings' ); 20 23 $parent_file = 'settings.php'; 21 24 25 /** 26 * Display JavaScript on the page. 27 * 28 * @since 4.1.0 29 */ 30 function network_settings_add_js() { 31 ?> 32 <script type="text/javascript"> 33 jQuery(document).ready( function($) { 34 var languageSelect = $( '#WPLANG' ); 35 $( 'form' ).submit( function() { 36 // Don't show a spinner for English and installed languages, 37 // as there is nothing to download. 38 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) { 39 $( '#submit', this ).after( '<span class="spinner language-install-spinner" />' ); 40 } 41 }); 42 }); 43 </script> 44 <?php 45 } 46 add_action( 'admin_head', 'network_settings_add_js' ); 47 22 48 get_current_screen()->add_help_tab( array( 23 49 'id' => 'overview', 24 50 'title' => __('Overview'), … … 58 84 'illegal_names', 'limited_email_domains', 'banned_email_domains', 'WPLANG', 'admin_email', 59 85 ); 60 86 87 // Handle translation install. 88 if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) { // @todo: Skip if already installed 89 $language = wp_download_language_pack( $_POST['WPLANG'] ); 90 if ( $language ) { 91 $_POST['WPLANG'] = $language; 92 } 93 } 94 61 95 foreach ( $options as $option_name ) { 62 96 if ( ! isset($_POST[$option_name]) ) 63 97 continue; … … 275 309 276 310 <?php 277 311 $languages = get_available_languages(); 278 if ( ! empty( $languages ) ) { 312 $translations = wp_get_available_translations(); 313 if ( ! empty( $languages ) || ! empty( $translations ) ) { 279 314 ?> 280 315 <h3><?php _e( 'Language Settings' ); ?></h3> 281 316 <table class="form-table"> … … 289 324 } 290 325 291 326 wp_dropdown_languages( array( 292 'name' => 'WPLANG', 293 'id' => 'WPLANG', 294 'selected' => $lang, 295 'languages' => $languages, 327 'name' => 'WPLANG', 328 'id' => 'WPLANG', 329 'selected' => $lang, 330 'languages' => $languages, 331 'translations' => $translations, 332 'show_available_translations' => wp_can_install_language_pack(), 296 333 ) ); 297 334 ?> 298 335 </td> -
src/wp-admin/options-general.php
9 9 /** WordPress Administration Bootstrap */ 10 10 require_once( dirname( __FILE__ ) . '/admin.php' ); 11 11 12 /** WordPress Translation Install API */ 13 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 14 12 15 if ( ! current_user_can( 'manage_options' ) ) 13 16 wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); 14 17 … … 63 66 date : format.val() 64 67 }, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } ); 65 68 }); 69 70 var languageSelect = $( '#WPLANG' ); 71 $( 'form' ).submit( function() { 72 // Don't show a spinner for English and installed languages, 73 // as there is nothing to download. 74 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) { 75 $( '#submit', this ).after( '<span class="spinner language-install-spinner" />' ); 76 } 77 }); 66 78 }); 67 79 //]]> 68 80 </script> … … 318 330 319 331 <?php 320 332 $languages = get_available_languages(); 333 $translations = wp_get_available_translations(); 321 334 if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) { 322 335 $languages[] = WPLANG; 323 336 } 324 if ( $languages) {337 if ( ! empty( $languages ) || ! empty( $translations ) ) { 325 338 ?> 326 339 <tr> 327 340 <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th> … … 333 346 } 334 347 335 348 wp_dropdown_languages( array( 336 'name' => 'WPLANG', 337 'id' => 'WPLANG', 338 'selected' => $locale, 339 'languages' => $languages, 349 'name' => 'WPLANG', 350 'id' => 'WPLANG', 351 'selected' => $locale, 352 'languages' => $languages, 353 'translations' => $translations, 354 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(), 340 355 ) ); 341 356 342 357 // Add note about deprecated WPLANG constant. -
src/wp-admin/options.php
151 151 $options = $whitelist_options[ $option_page ]; 152 152 } 153 153 154 // Handle custom date/time formats.155 154 if ( 'general' == $option_page ) { 155 // Handle custom date/time formats. 156 156 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) 157 157 $_POST['date_format'] = $_POST['date_format_custom']; 158 158 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) … … 163 163 $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); 164 164 $_POST['timezone_string'] = ''; 165 165 } 166 167 // Handle translation install. 168 if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed 169 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 170 171 if ( wp_can_install_language_pack() ) { 172 $language = wp_download_language_pack( $_POST['WPLANG'] ); 173 if ( $language ) { 174 $_POST['WPLANG'] = $language; 175 } 176 } 177 } 166 178 } 167 179 168 180 if ( $options ) { -
src/wp-includes/l10n.php
852 852 * @param array $args Optional arguments. Default empty array. 853 853 */ 854 854 function wp_dropdown_languages( $args = array() ) { 855 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );856 855 857 856 $args = wp_parse_args( $args, array( 858 'id' => '', 859 'name' => '', 860 'languages' => array(), 861 'selected' => '' 857 'id' => '', 858 'name' => '', 859 'languages' => array(), 860 'translations' => array(), 861 'selected' => '', 862 'show_available_translations' => true, 862 863 ) ); 863 864 864 if ( empty( $args['languages'] ) ) { 865 return false; 865 $translations = $args['translations']; 866 if ( empty( $args['translations'] ) ) { 867 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 868 $translations = wp_get_available_translations(); 866 869 } 867 870 868 $translations = wp_get_available_translations();869 870 871 /* 871 872 * $args['languages'] should only contain the locales. Find the locale in 872 873 * $translations to get the native name. Fall back to locale. … … 880 881 'native_name' => $translation['native_name'], 881 882 'lang' => $translation['iso'][1], 882 883 ); 884 885 // Remove installed language from available translations. 886 unset( $translations[ $locale ] ); 883 887 } else { 884 888 $languages[] = array( 885 889 'language' => $locale, … … 891 895 892 896 printf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) ); 893 897 898 // Holds the HTML markup. 899 $structure = array(); 900 894 901 // List installed languages. 895 echo '<option value="" lang="en">English (United States)</option>'; 902 $structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">'; 903 $structure[] = '<option value="" lang="en" data-installed="1">English (United States)</option>'; 896 904 foreach ( $languages as $language ) { 897 $selected = selected( $language['language'], $args['selected'], false ); 898 printf( 899 '<option value="%s" lang="%s"%s>%s</option>', 905 $structure[] = sprintf( 906 '<option value="%s" lang="%s"%s data-installed="1">%s</option>', 900 907 esc_attr( $language['language'] ), 901 908 esc_attr( $language['lang'] ), 902 $selected,909 selected( $language['language'], $args['selected'], false ), 903 910 esc_html( $language['native_name'] ) 904 911 ); 905 912 } 913 $structure[] = '</optgroup>'; 906 914 915 // List available translations. 916 if ( ! empty( $translations ) && $args['show_available_translations'] ) { 917 $structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">'; 918 foreach ( $translations as $translation ) { 919 $structure[] = sprintf( 920 '<option value="%s" lang="%s"%s>%s</option>', 921 esc_attr( $translation['language'] ), 922 esc_attr( $translation['iso'][1] ), 923 selected( $translation['language'], $args['selected'], false ), 924 esc_html( $translation['native_name'] ) 925 ); 926 } 927 $structure[] = '</optgroup>'; 928 } 929 930 echo join( "\n", $structure ); 931 907 932 echo '</select>'; 908 933 }