WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/09/2010 06:14:42 AM (12 years ago)
Author:
nacin
Message:

Allow localhost in a multisite subdirectory install. More network.php improvements. see #12457 for localhost. see #11816

File:
1 edited

Legend:

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

    r13614 r13622  
    5757
    5858    $hostname = get_clean_basedomain();
    59     if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) {
     59    if ( preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) {
    6060        echo '<p><strong>' . __('You cannot install a network of sites with your server address.' ) . '</strong></p>';
    61         echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code> or a single-word hostname like <code>localhost</code>.' ) . '</p>';
    62         if ( 'localhost' == $hostname )
    63             echo '<p>' . __('Consider using <code>localhost.localdomain</code>.') . '</p>';
     61        echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code>.' ) . '</p>';
    6462        include( './admin-footer.php' );
    6563        die();
     
    9492<?php   } ?>
    9593        <input type='hidden' name='action' value='step2' />
     94<?php   if ( 'localhost' != $hostname ) : ?>
    9695        <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
    97    
    9896        <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
    9997        <p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p>
     
    114112
    115113        <?php
     114        endif;
     115
    116116        $is_www = ( substr( $hostname, 0, 4 ) == 'www.' );
    117117        if ( $is_www ) :
     
    132132        <h3><?php esc_html_e( 'Network Details' ); ?></h3>
    133133        <table class="form-table">
     134        <?php if ( 'localhost' == $hostname ) : ?>
     135            <tr>
     136                <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
     137                <td><?php _e('Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.'); ?></td>
     138            </tr>
     139        <?php endif; ?>
    134140        <?php if ( ! $is_www ) : ?>
    135141            <tr>
     
    175181                <textarea class="code" readonly="readonly" cols="100" rows="7">
    176182define( 'MULTISITE', true );
    177 define( 'VHOST', '<?php echo 'yes' == stripslashes( $_POST['vhost'] ) ? 'yes' : 'no'; ?>' );
     183define( 'VHOST', '<?php echo ( ! empty( $_POST['vhost'] ) && 'yes' == stripslashes( $_POST['vhost'] ) ) ? 'yes' : 'no'; ?>' );
    178184$base = '<?php echo $base; ?>';
    179185define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' );
     
    258264        // create network tables
    259265        install_network();
     266        $hostname = get_clean_basedomain();
     267        $vhost = 'localhost' == $hostname ? false : (bool) $_POST['vhost'];
    260268        if ( !network_domain_check() || isset( $_POST['existing_network'] ) && $_POST['existing_network'] == '0' )
    261             populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
     269            populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $vhost );
    262270        // create wp-config.php / htaccess
    263271        network_step2();
Note: See TracChangeset for help on using the changeset viewer.