]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/network/settings.php
WordPress 4.1-scripts
[autoinstalls/wordpress.git] / wp-admin / network / settings.php
index 3497ddb007a76c63f7de61f84b5a5331d08f3079..d3d8584f9e658822f8a1056935e2cfbeb82f5ab8 100644 (file)
@@ -10,6 +10,9 @@
 /** Load WordPress Administration Bootstrap */
 require_once( dirname( __FILE__ ) . '/admin.php' );
 
+/** WordPress Translation Install API */
+require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
+
 if ( ! is_multisite() )
        wp_die( __( 'Multisite support is not enabled.' ) );
 
@@ -19,6 +22,29 @@ if ( ! current_user_can( 'manage_network_options' ) )
 $title = __( 'Network Settings' );
 $parent_file = 'settings.php';
 
+/**
+ * Print JavaScript in the header on the Network Settings screen.
+ *
+ * @since 4.1.0
+*/
+function network_settings_add_js() {
+?>
+<script type="text/javascript">
+jQuery(document).ready( function($) {
+       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>
+<?php
+}
+add_action( 'admin_head', 'network_settings_add_js' );
+
 get_current_screen()->add_help_tab( array(
                'id'      => 'overview',
                'title'   => __('Overview'),
@@ -28,6 +54,7 @@ get_current_screen()->add_help_tab( array(
                        '<p>' . __('Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.') . '</p>' .
                        '<p>' . __('New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what&#8127;s put in the first post, page, comment, comment author, and comment URL.') . '</p>' .
                        '<p>' . __('Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).') . '</p>' .
+                       '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' .
                        '<p>' . __('Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.') . '</p>' .
                        '<p>' . __('Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Network Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.') . '</p>'
 ) );
@@ -58,6 +85,14 @@ if ( $_POST ) {
                'illegal_names', 'limited_email_domains', 'banned_email_domains', 'WPLANG', 'admin_email',
        );
 
+       // Handle translation install.
+       if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) {  // @todo: Skip if already installed
+               $language = wp_download_language_pack( $_POST['WPLANG'] );
+               if ( $language ) {
+                       $_POST['WPLANG'] = $language;
+               }
+       }
+
        foreach ( $options as $option_name ) {
                if ( ! isset($_POST[$option_name]) )
                        continue;
@@ -85,7 +120,7 @@ if ( isset( $_GET['updated'] ) ) {
 
 <div class="wrap">
        <h2><?php echo esc_html( $title ); ?></h2>
-       <form method="post" action="settings.php">
+       <form method="post" action="settings.php" novalidate="novalidate">
                <?php wp_nonce_field( 'siteoptions' ); ?>
                <h3><?php _e( 'Operational Settings' ); ?></h3>
                <table class="form-table">
@@ -99,10 +134,10 @@ if ( isset( $_GET['updated'] ) ) {
                        <tr>
                                <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ) ?></label></th>
                                <td>
-                                       <input name="admin_email" type="text" id="admin_email" class="regular-text" value="<?php echo esc_attr( get_site_option('admin_email') ) ?>" />
+                                       <input name="admin_email" type="email" id="admin_email" class="regular-text" value="<?php echo esc_attr( get_site_option( 'admin_email' ) ) ?>" />
                                        <p class="description">
                                                <?php _e( 'This email address will receive notifications. Registration and support emails will also come from this address.' ); ?>
-                                       </p>    
+                                       </p>
                                </td>
                        </tr>
                </table>
@@ -165,7 +200,7 @@ if ( isset( $_GET['updated'] ) ) {
 <?php echo esc_textarea( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
                                        <p class="description">
                                                <?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ) ?>
-                                       </p>    
+                                       </p>
                                </td>
                        </tr>
 
@@ -231,7 +266,7 @@ if ( isset( $_GET['updated'] ) ) {
 <?php echo esc_textarea( get_site_option( 'first_comment' ) ) ?></textarea>
                                        <p class="description">
                                                <?php _e( 'The first comment on a new site.' ) ?>
-                                       </p>    
+                                       </p>
                                </td>
                        </tr>
                        <tr>
@@ -264,7 +299,7 @@ if ( isset( $_GET['updated'] ) ) {
 
                        <tr>
                                <th scope="row"><label for="upload_filetypes"><?php _e( 'Upload file types' ) ?></label></th>
-                               <td><input name="upload_filetypes" type="text" id="upload_filetypes" class="large-text" value="<?php echo esc_attr( get_site_option('upload_filetypes', 'jpg jpeg png gif') ) ?>" size="45" /></td>
+                               <td><input name="upload_filetypes" type="text" id="upload_filetypes" class="large-text" value="<?php echo esc_attr( get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) ) ?>" size="45" /></td>
                        </tr>
 
                        <tr>
@@ -273,25 +308,37 @@ if ( isset( $_GET['updated'] ) ) {
                        </tr>
                </table>
 
-<?php
+               <?php
                $languages = get_available_languages();
-               if ( ! empty( $languages ) ) {
-                       $lang = get_site_option( 'WPLANG' );
-?>
-               <h3><?php _e( 'Language Settings' ); ?></h3>
-               <table class="form-table">
+               $translations = wp_get_available_translations();
+               if ( ! empty( $languages ) || ! empty( $translations ) ) {
+                       ?>
+                       <h3><?php _e( 'Language Settings' ); ?></h3>
+                       <table class="form-table">
                                <tr>
                                        <th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th>
                                        <td>
-                                               <select name="WPLANG" id="WPLANG">
-                                                       <?php mu_dropdown_languages( $languages, get_site_option( 'WPLANG' ) ); ?>
-                                               </select>
+                                               <?php
+                                               $lang = get_site_option( 'WPLANG' );
+                                               if ( ! in_array( $lang, $languages ) ) {
+                                                       $lang = '';
+                                               }
+
+                                               wp_dropdown_languages( array(
+                                                       'name'         => 'WPLANG',
+                                                       'id'           => 'WPLANG',
+                                                       'selected'     => $lang,
+                                                       'languages'    => $languages,
+                                                       'translations' => $translations,
+                                                       'show_available_translations' => wp_can_install_language_pack(),
+                                               ) );
+                                               ?>
                                        </td>
                                </tr>
-               </table>
-<?php
-               } // languages
-?>
+                       </table>
+                       <?php
+               }
+               ?>
 
                <h3><?php _e( 'Menu Settings' ); ?></h3>
                <table id="menu" class="form-table">
@@ -324,7 +371,7 @@ if ( isset( $_GET['updated'] ) ) {
                        </tr>
                </table>
 
-               <?php 
+               <?php
                /**
                 * Fires at the end of the Network Settings form, before the submit button.
                 *