Make WordPress Core


Ignore:
Timestamp:
07/05/2014 05:13:05 AM (10 years ago)
Author:
nacin
Message:

Bring the language chooser to setup-config.php.

see #28577.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/setup-config.php

    r29005 r29006  
    2727 * Set this to error_reporting( -1 ) for debugging
    2828 */
    29 error_reporting(-1);
     29error_reporting(0);
    3030
    3131define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
    3232
    3333require( ABSPATH . 'wp-settings.php' );
     34
     35require( ABSPATH . 'wp-admin/includes/upgrade.php' );
    3436
    3537// Support wp-config-sample.php one level up, for the develop repo.
     
    4951    wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>."), 'install.php' ) . '</p>' );
    5052
    51 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
     53$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : -1;
    5254
    5355/**
     
    5759 * @since 2.3.0
    5860 */
    59 function setup_config_display_header() {
     61function setup_config_display_header( $body_classes = array() ) {
    6062    global $wp_version;
     63    $body_classes = (array) $body_classes;
     64    $body_classes[] = 'wp-core-ui';
     65    if ( is_rtl() ) {
     66        $body_classes[] = 'rtl';
     67    }
    6168
    6269    header( 'Content-Type: text/html; charset=utf-8' );
     
    7279
    7380</head>
    74 <body class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>">
     81<body class="<?php echo implode( ' ', $body_classes ); ?>">
    7582<h1 id="logo"><a href="<?php esc_attr_e( 'https://wordpress.org/' ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1>
    7683<?php
     
    7885
    7986switch($step) {
     87    case -1:
     88
     89        if ( empty( $_GET['language'] ) && ( $body = wp_get_available_translations() ) ) {
     90            setup_config_display_header( 'language-chooser' );
     91            echo '<form id="setup" method="post" action="?step=0">';
     92            wp_install_language_form( $body );
     93            echo '</form>';
     94            break;
     95        }
     96
     97        // Deliberately fall through if we can't reach the translations API.
     98
    8099    case 0:
     100        if ( ! empty( $_REQUEST['language'] ) ) {
     101            $loaded_language = wp_install_download_language_pack( $_REQUEST['language'] );
     102            if ( $loaded_language ) {
     103                wp_install_load_language( $loaded_language );
     104            }
     105        }
     106
    81107        setup_config_display_header();
     108        $step_1 = 'setup-config.php?step=1';
     109        if ( isset( $_REQUEST['noapi'] ) ) {
     110            $step_1 .= '&amp;noapi';
     111        }
     112        if ( ! empty( $loaded_language ) ) {
     113            $step_1 .= '&amp;language=' . $loaded_language;
     114        }
    82115?>
    83116
     
    97130<p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
    98131
    99 <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button button-large"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
     132<p class="step"><a href="<?php echo $step_1; ?>" class="button button-large"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
    100133<?php
    101134    break;
    102135
    103136    case 1:
     137        $loaded_language = wp_install_load_language( $_REQUEST['language'] );
    104138        setup_config_display_header();
    105139    ?>
     
    134168    </table>
    135169    <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
     170    <input type="hidden" name="language" value="<?php echo esc_attr( $loaded_language ); ?>" />
    136171    <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p>
    137172</form>
     
    140175
    141176    case 2:
     177    $loaded_language = wp_install_load_language( $_REQUEST['language'] );
    142178    $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) );
    143179    $uname = trim( wp_unslash( $_POST[ 'uname' ] ) );
     
    146182    $prefix = trim( wp_unslash( $_POST[ 'prefix' ] ) );
    147183
    148     $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
     184    $step_1 = 'setup-config.php?step=1';
     185    $install = 'install.php';
     186    if ( isset( $_REQUEST['noapi'] ) ) {
     187        $step_1 .= '&amp;noapi';
     188    }
     189    if ( $loaded_language ) {
     190        $step_1 .= '&amp;language=' . $loaded_language;
     191        $install .= '?language=' . $loaded_language;
     192    }
     193    $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
    149194
    150195    if ( empty( $prefix ) )
     
    240285?></textarea>
    241286<p><?php _e( 'After you&#8217;ve done that, click &#8220;Run the install.&#8221;' ); ?></p>
    242 <p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
     287<p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
    243288<script>
    244289(function(){
     
    267312<p><?php _e( "All right, sparky! You&#8217;ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;" ); ?></p>
    268313
    269 <p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
     314<p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
    270315<?php
    271316    endif;
Note: See TracChangeset for help on using the changeset viewer.