Multisite: Allow to set the site language of a new site to English.

An empty string in `WPLANG` is used to define the site language as `en_US`. The `! empty()` check didn't catch this case so that `wpmu_create_blog()` fell back to the network setting.

Fixes #36918.
Built from https://develop.svn.wordpress.org/trunk@38655


git-svn-id: http://core.svn.wordpress.org/trunk@38598 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-09-26 18:39:32 +00:00
parent a1ef815d04
commit 4a6f90db58
3 changed files with 13 additions and 7 deletions

View File

@ -65,10 +65,14 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) {
);
// 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 ( isset( $_POST['WPLANG'] ) ) {
if ( '' === $_POST['WPLANG'] ) {
$meta['WPLANG'] = ''; // en_US
} elseif ( wp_can_install_language_pack() ) {
$language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
if ( $language ) {
$meta['WPLANG'] = $language;
}
}
}

View File

@ -1092,7 +1092,10 @@ function wpmu_create_user( $user_name, $password, $email ) {
* @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success
*/
function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
$defaults = array( 'public' => 0 );
$defaults = array(
'public' => 0,
'WPLANG' => get_site_option( 'WPLANG' ),
);
$meta = wp_parse_args( $meta, $defaults );
$domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
@ -1130,7 +1133,6 @@ function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $s
update_option( $key, $value );
}
add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
update_option( 'blog_public', (int) $meta['public'] );
if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )

View File

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