Skip to content

Commit

Permalink
Multisite: Allow to set the site language of a new site to English.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ocean90 committed Sep 26, 2016
1 parent a1ef815 commit 4a6f90d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions wp-admin/network/site-new.php
Expand Up @@ -65,10 +65,14 @@
);

// 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;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions wp-includes/ms-functions.php
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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 ) )
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -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.
Expand Down

0 comments on commit 4a6f90d

Please sign in to comment.