Make WordPress Core


Ignore:
Timestamp:
03/10/2010 08:17:07 AM (17 years ago)
Author:
nacin
Message:

Correct subdomain handling in network.php. Pass around boolean values instead of 'yes' and 'no'. see #11816

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network.php

    r13638 r13641  
    9999                <table class="form-table">
    100100                        <tr>
    101                                 <th><label><input type='radio' name='vhost' value='yes'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th>
     101                                <th><label><input type='radio' name='subdomain_install' value='1'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th>
    102102                                <td><?php _e('like <code>site1.example.com</code> and <code>site2.example.com</code>'); ?></td>
    103103                        </tr>
    104104                        <tr>
    105                                 <th><label><input type='radio' name='vhost' value='no'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th>
     105                                <th><label><input type='radio' name='subdomain_install' value='0'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th>
    106106                                <td><?php _e('like <code>example.com/site1</code> and <code>example.com/site2</code>'); ?></td>
    107107                        </tr>
    … …  
    169169function network_step2() {
    170170        global $base, $wpdb;
    171         if ( ! $_POST ) :
    172                 if ( is_multisite() ) : ?>
     171        if ( $_POST ) {
     172                $vhost = (bool) $_POST['subdomain_install'];
     173        } else {
     174                if ( is_multisite() ) {
     175                        $vhost = is_subdomain_install();
     176?>
    173177        <div class="updated"><p><strong><?php _e( 'Notice: The Network feature is already enabled.' ); ?></strong> <?php _e( 'The original configuration steps are shown here for reference.' ); ?></p></div>
    174 <?php   else : ?>
     178<?php   } else {
     179                        $vhost = false; // @todo.
     180?>
    175181        <div class="error"><p><strong><?php _e('Warning:'); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
    176182        <p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
    … …  
    179185                <div class="updated inline"><p><?php _e( '<strong>Caution:</strong> We recommend you backup your existing <code>wp-config.php</code> and <code>.htaccess</code> files.' ); ?></p></div>
    180186<?php
    181                 endif;
    182         endif;
     187                }
     188        }
    183189?>
    184190                <ol>
    … …  
    187193                                <textarea class="code" readonly="readonly" cols="100" rows="7">
    188194define( 'MULTISITE', true );
    189 define( 'VHOST', '<?php echo ( ! empty( $_POST['vhost'] ) && 'yes' == stripslashes( $_POST['vhost'] ) ) ? 'yes' : 'no'; ?>' );
     195define( 'VHOST', '<?php echo $vhost ? 'yes' : 'no'; ?>' );
    190196$base = '<?php echo $base; ?>';
    191197define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' );
    … …  
    260266}
    261267
     268$base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
     269
    262270if ( $_POST ) {
    263271        check_admin_referer( 'install-network-1' );
    264 
    265         // Install!
    266         $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
    267272
    268273        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    … …  
    270275        install_network();
    271276        $hostname = get_clean_basedomain();
    272         $vhost = 'localhost' == $hostname ? false : (bool) $_POST['vhost'];
     277        $subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
    273278        if ( ! network_domain_check() )
    274                 populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $vhost );
     279                populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $subdomain_install );
    275280        // create wp-config.php / htaccess
    276281        network_step2();
Note: See TracChangeset for help on using the changeset viewer.