Make WordPress Core

Changeset 33920


Ignore:
Timestamp:
09/05/2015 08:47:00 PM (9 years ago)
Author:
johnbillion
Message:

Implement a language chooser on the Network Admin -> Sites -> Add New screen.

Props DrewAPicture
Fixes #33528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/site-new.php

    r33620 r33920  
    1111require_once( dirname( __FILE__ ) . '/admin.php' );
    1212
     13/** WordPress Translation Install API */
     14require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
     15
    1316if ( ! is_multisite() )
    1417    wp_die( __( 'Multisite support is not enabled.' ) );
     
    5154
    5255    $title = $blog['title'];
     56
     57    $meta = array(
     58        'public' => 1
     59    );
     60
     61    // Handle translation install for the new site.
     62    if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) {
     63        $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
     64        if ( $language ) {
     65            $meta['WPLANG'] = $language;
     66        }
     67    }
    5368
    5469    if ( empty( $domain ) )
     
    8499
    85100    $wpdb->hide_errors();
    86     $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
     101    $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, $current_site->id );
    87102    $wpdb->show_errors();
    88103    if ( ! is_wp_error( $id ) ) {
     
    156171            <td><input name="blog[title]" type="text" class="regular-text" id="site-title" /></td>
    157172        </tr>
     173        <?php
     174        $languages    = get_available_languages();
     175        $translations = wp_get_available_translations();
     176        if ( ! empty( $languages ) || ! empty( $translations ) ) :
     177            ?>
     178            <tr class="form-field form-required">
     179                <th scope="row"><label for="site-language"><?php _e( 'Site Language' ); ?></label></th>
     180                <td>
     181                    <?php
     182                    // Network default.
     183                    $lang = get_site_option( 'WPLANG' );
     184
     185                    // Use English if the default isn't available.
     186                    if ( ! in_array( $lang, $languages ) ) {
     187                        $lang = '';
     188                    }
     189
     190                    wp_dropdown_languages( array(
     191                        'name'                        => 'WPLANG',
     192                        'id'                          => 'site-language',
     193                        'selected'                    => $lang,
     194                        'languages'                   => $languages,
     195                        'translations'                => $translations,
     196                        'show_available_translations' => wp_can_install_language_pack(),
     197                    ) );
     198                    ?>
     199                </td>
     200            </tr>
     201        <?php endif; // Languages. ?>
    158202        <tr class="form-field form-required">
    159203            <th scope="row"><label for="admin-email"><?php _e( 'Admin Email' ) ?></label></th>
Note: See TracChangeset for help on using the changeset viewer.