WordPress.org

Make WordPress Core

Changeset 13926


Ignore:
Timestamp:
04/02/2010 02:04:25 AM (8 years ago)
Author:
wpmuguru
Message:

block subdomain install when install is in a folder, see #12736

File:
1 edited

Legend:

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

    r13904 r13926  
    3737}
    3838
     39/**
     40 * Allow subdomain install
     41 *
     42 * @since 3.0.0
     43 * @return bool - whether subdomain install is allowed
     44 */
     45function allow_subdomain_install() {
     46    $path = preg_replace( '|https?://[^/]|', '', get_option( 'siteurl' ) );
     47    if( strlen( $path ) > 1 || 'localhost' == $_SERVER[ 'HTTP_HOST' ] )
     48        return false;
     49
     50    return true;
     51}
    3952/**
    4053 * Get base domain of network.
     
    135148    }
    136149
    137     if ( 'localhost' != $hostname ) : ?>
     150    if ( allow_subdomain_install() ) : ?>
    138151        <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
    139152        <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>
     
    176189                <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>
    177190            </tr>
     191        <?php elseif ( !allow_subdomain_install() ) : ?>
     192            <tr>
     193                <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
     194                <td><?php _e('Because your install is in a directory, the sites in your WordPress network must use sub-directories.'); ?></td>
     195            </tr>
    178196        <?php endif; ?>
    179197        <?php if ( ! $is_www ) : ?>
     
    218236
    219237    if ( $_POST ) {
    220         $vhost = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
     238        $vhost = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
    221239    } else {
    222240        if ( is_multisite() ) {
     
    327345    install_network();
    328346    $hostname = get_clean_basedomain();
    329     $subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
     347    $subdomain_install = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
    330348    if ( ! network_domain_check() ) {
    331349        $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['sitename'], $base, $subdomain_install );
Note: See TracChangeset for help on using the changeset viewer.