Changeset 38655
- Timestamp:
- 09/26/2016 06:38:32 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/network/site-new.php
r37914 r38655 66 66 67 67 // Handle translation install for the new site. 68 if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) { 69 $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) ); 70 if ( $language ) { 71 $meta['WPLANG'] = $language; 68 if ( isset( $_POST['WPLANG'] ) ) { 69 if ( '' === $_POST['WPLANG'] ) { 70 $meta['WPLANG'] = ''; // en_US 71 } elseif ( wp_can_install_language_pack() ) { 72 $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) ); 73 if ( $language ) { 74 $meta['WPLANG'] = $language; 75 } 72 76 } 73 77 } -
trunk/src/wp-includes/ms-functions.php
r38636 r38655 1093 1093 */ 1094 1094 function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) { 1095 $defaults = array( 'public' => 0 ); 1095 $defaults = array( 1096 'public' => 0, 1097 'WPLANG' => get_site_option( 'WPLANG' ), 1098 ); 1096 1099 $meta = wp_parse_args( $meta, $defaults ); 1097 1100 … … 1131 1134 } 1132 1135 1133 add_option( 'WPLANG', get_site_option( 'WPLANG' ) );1134 1136 update_option( 'blog_public', (int) $meta['public'] ); 1135 1137 -
trunk/tests/phpunit/tests/multisite/site.php
r37665 r38655 927 927 } 928 928 929 /** 930 * @ticket 36918 931 */ 932 function test_new_blog_locale() { 933 $current_site = get_current_site(); 934 935 add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 ); 936 update_site_option( 'WPLANG', 'de_DE' ); 937 remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 ); 938 939 // No locale, use default locale. 940 add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 ); 941 $blog_id = wpmu_create_blog( $current_site->domain, '/de-de/', 'New Blog', get_current_user_id() ); 942 remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 ); 943 944 $this->assertNotWPError( $blog_id ); 945 $this->assertSame( 'de_DE', get_blog_option( $blog_id, 'WPLANG' ) ); 946 947 // Custom locale. 948 add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 ); 949 $blog_id = wpmu_create_blog( $current_site->domain, '/es-es/', 'New Blog', get_current_user_id(), array( 'WPLANG' => 'es_ES' ) ); 950 remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 ); 951 952 $this->assertNotWPError( $blog_id ); 953 $this->assertSame( 'es_ES', get_blog_option( $blog_id, 'WPLANG' ) ); 954 955 // en_US locale. 956 add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 ); 957 $blog_id = wpmu_create_blog( $current_site->domain, '/en-us/', 'New Blog', get_current_user_id(), array( 'WPLANG' => '' ) ); 958 remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 ); 959 960 $this->assertNotWPError( $blog_id ); 961 $this->assertSame( '', get_blog_option( $blog_id, 'WPLANG' ) ); 962 } 963 964 /** 965 * Allows to set the WPLANG option to any language. 966 * 967 * @param string $value The sanitized option value. 968 * @param string $option The option name. 969 * @param string $original_value The original value passed to the function. 970 * @return string The orginal value. 971 */ 972 function filter_allow_unavailable_languages( $value, $option, $original_value ) { 973 return $original_value; 974 } 929 975 } 930 976
Note: See TracChangeset
for help on using the changeset viewer.