]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/options-general.php
WordPress 4.1.3
[autoinstalls/wordpress.git] / wp-admin / options-general.php
index 701188555353a3b4de1734327b99b4a90397cb31..629c4d2f35e066013734a7b0d696487dcd8ae985 100644 (file)
@@ -9,6 +9,9 @@
 /** WordPress Administration Bootstrap */
 require_once( dirname( __FILE__ ) . '/admin.php' );
 
+/** WordPress Translation Install API */
+require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
+
 if ( ! current_user_can( 'manage_options' ) )
        wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
 
@@ -27,6 +30,20 @@ function options_general_add_js() {
 <script type="text/javascript">
 //<![CDATA[
        jQuery(document).ready(function($){
+               var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
+                       homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
+
+               $( '#blogname' ).on( 'input', function() {
+                       var title = $.trim( $( this ).val() ) || homeURL;
+
+                       // Truncate to 40 characters.
+                       if ( 40 < title.length ) {
+                               title = title.substring( 0, 40 ) + '\u2026';
+                       }
+
+                       $siteName.text( title );
+               });
+
                $("input[name='date_format']").click(function(){
                        if ( "date_format_custom_radio" != $(this).attr("id") )
                                $("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
@@ -50,6 +67,15 @@ function options_general_add_js() {
                                        date : format.val()
                                }, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
                });
+
+               var languageSelect = $( '#WPLANG' );
+               $( 'form' ).submit( function() {
+                       // Don't show a spinner for English and installed languages,
+                       // as there is nothing to download.
+                       if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
+                               $( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
+                       }
+               });
        });
 //]]>
 </script>
@@ -65,7 +91,8 @@ if ( ! is_multisite() ) {
                '<p>' . __('If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.') . '</p>';
 }
 
-$options_help .= '<p>' . __('UTC means Coordinated Universal Time.') . '</p>' .
+$options_help .= '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' .
+       '<p>' . __( 'UTC means Coordinated Universal Time.' ) . '</p>' .
        '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>';
 
 get_current_screen()->add_help_tab( array(
@@ -305,10 +332,11 @@ endfor;
 
 <?php
 $languages = get_available_languages();
+$translations = wp_get_available_translations();
 if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) {
        $languages[] = WPLANG;
 }
-if ( $languages ) {
+if ( ! empty( $languages ) || ! empty( $translations ) ) {
        ?>
        <tr>
                <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th>
@@ -320,10 +348,12 @@ if ( $languages ) {
                        }
 
                        wp_dropdown_languages( array(
-                               'name'      => 'WPLANG',
-                               'id'        => 'WPLANG',
-                               'selected'  => $locale,
-                               'languages' => $languages,
+                               'name'         => 'WPLANG',
+                               'id'           => 'WPLANG',
+                               'selected'     => $locale,
+                               'languages'    => $languages,
+                               'translations' => $translations,
+                               'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(),
                        ) );
 
                        // Add note about deprecated WPLANG constant.