Changeset 28774 for trunk/src/wp-admin/install.php
- Timestamp:
- 06/18/2014 07:57:21 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/install.php
r28759 r28774 45 45 46 46 /** 47 * @todo rename, move 48 */ 49 function wp_get_available_translations() { 50 $url = 'http://api.wordpress.org/translations/core/1.0/'; 51 if ( wp_http_supports( array( 'ssl' ) ) ) { 52 $url = set_url_scheme( $url, 'https' ); 53 } 54 55 $options = array( 56 'timeout' => 3, 57 'body' => array( 'version' => $GLOBALS['wp_version'] ), 58 ); 59 60 $response = wp_remote_post( $url, $options ); 61 $body = wp_remote_retrieve_body( $response ); 62 if ( $body && $body = json_decode( $body, true ) ) { 63 return $body; 64 } 65 return false; 66 } 67 68 /** 47 69 * Display install header. 48 70 * … … 137 159 </table> 138 160 <p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p> 161 <input type="hidden" name="language" value="<?php echo isset( $_POST['language'] ) ? esc_attr( $_POST['language'] ) : ''; ?>" /> 139 162 </form> 140 163 <?php … … 170 193 171 194 switch($step) { 172 case 0: // Step 1 173 case 1: // Step 1, direct link. 174 display_header(); 195 case 0: // Step 0 196 if ( $body = wp_get_available_translations() ) { 197 display_header(); 198 199 echo '<form id="setup" method="post" action="install.php?step=1">'; 200 echo '<div class="language-chooser">'; 201 echo '<select name="language" id="language-chooser" size="15">'; 202 echo '<option selected="selected" value="">English (United States)</option>'; 203 foreach ( $body['languages'] as $language ) { 204 echo '<option value="' . esc_attr( $language['language'] ) . '">' . esc_html( $language['native_name'] ) . "</option>\n"; 205 } 206 echo "</select>\n"; 207 echo '<p class="step"><input type="submit" class="button button-primary button-hero" value="»" /></p>'; 208 echo '</div>'; 209 echo '</form>'; 210 break; 211 } 212 // Deliberately fall through if we can't reach the translations API. 213 214 case 1: // Step 1, direct link or from language chooser. 215 if ( ! empty( $_POST['language'] ) ) { 216 $body = wp_get_available_translations(); 217 foreach ( $body['languages'] as $language ) { 218 if ( $language['language'] === $_POST['language'] ) { 219 $loading_language = $_POST['language']; 220 break; 221 } 222 } 223 if ( ! empty( $loading_language ) ) { 224 require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 225 $skin = new Automatic_Upgrader_Skin; 226 $upgrader = new Language_Pack_Upgrader( $skin ); 227 $options = array( 'clear_update_cache' => false ); 228 $language['type'] = 'core'; 229 $language = (object) $language; 230 /** 231 * @todo failures (such as non-direct FS) 232 */ 233 $upgrader->upgrade( $language, array( 'clear_update_cache' => false ) ); 234 load_textdomain( 'default', WP_LANG_DIR . "/{$loading_language}.mo" ); 235 load_textdomain( 'default', WP_LANG_DIR . "/admin-{$loading_language}.mo" ); 236 } 237 } 238 239 display_header(); 175 240 ?> 176 241 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> … … 184 249 break; 185 250 case 2: 251 $loading_language = ''; 252 if ( ! empty( $_POST['language'] ) ) { 253 $available_languages = get_available_languages(); 254 if ( isset( $available_languages[ $_POST['language'] ] ) ) { 255 $loading_language = $_POST['language']; 256 load_textdomain( 'default', WP_LANG_DIR . "/{$loading_language}.mo" ); 257 load_textdomain( 'default', WP_LANG_DIR . "/admin-{$loading_language}.mo" ); 258 } 259 } 260 186 261 if ( ! empty( $wpdb->error ) ) 187 262 wp_die( $wpdb->error->get_error_message() ); … … 220 295 if ( $error === false ) { 221 296 $wpdb->show_errors(); 222 $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ) );297 $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loading_language ); 223 298 ?> 224 299 … … 251 326 if ( !wp_is_mobile() ) { 252 327 ?> 253 <script type="text/javascript">var t = document.getElementById('weblog_title') ; if (t){ t.focus(); }</script>328 <script type="text/javascript">var t = document.getElementById('weblog_title') || document.getElementById('language-chooser'); if (t){ t.focus(); }</script> 254 329 <?php } ?> 255 330 <?php wp_print_scripts( 'user-profile' ); ?>
Note: See TracChangeset
for help on using the changeset viewer.