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

Props DrewAPicture
Fixes #33528

Built from https://develop.svn.wordpress.org/trunk@33920


git-svn-id: http://core.svn.wordpress.org/trunk@33889 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-09-05 20:47:24 +00:00
parent 695d3ee98b
commit 4d76ce2521
2 changed files with 46 additions and 2 deletions

View 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.' ) );
@ -51,6 +54,18 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) {
$title = $blog['title'];
$meta = array(
'public' => 1
);
// Handle translation install for the new site.
if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
if ( $language ) {
$meta['WPLANG'] = $language;
}
}
if ( empty( $domain ) )
wp_die( __( 'Missing or invalid site address.' ) );
@ -83,7 +98,7 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) {
}
$wpdb->hide_errors();
$id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
$id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, $current_site->id );
$wpdb->show_errors();
if ( ! is_wp_error( $id ) ) {
if ( ! is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) ) {
@ -155,6 +170,35 @@ if ( ! empty( $messages ) ) {
<th scope="row"><label for="site-title"><?php _e( 'Site Title' ) ?></label></th>
<td><input name="blog[title]" type="text" class="regular-text" id="site-title" /></td>
</tr>
<?php
$languages = get_available_languages();
$translations = wp_get_available_translations();
if ( ! empty( $languages ) || ! empty( $translations ) ) :
?>
<tr class="form-field form-required">
<th scope="row"><label for="site-language"><?php _e( 'Site Language' ); ?></label></th>
<td>
<?php
// Network default.
$lang = get_site_option( 'WPLANG' );
// Use English if the default isn't available.
if ( ! in_array( $lang, $languages ) ) {
$lang = '';
}
wp_dropdown_languages( array(
'name' => 'WPLANG',
'id' => 'site-language',
'selected' => $lang,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => wp_can_install_language_pack(),
) );
?>
</td>
</tr>
<?php endif; // Languages. ?>
<tr class="form-field form-required">
<th scope="row"><label for="admin-email"><?php _e( 'Admin Email' ) ?></label></th>
<td><input name="blog[email]" type="email" class="regular-text wp-suggest-user" id="admin-email" data-autocomplete-type="search" data-autocomplete-field="user_email" /></td>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-33919';
$wp_version = '4.4-alpha-33920';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.