WordPress.org

Make WordPress Core

Ticket #22639: 22639.2.diff

File 22639.2.diff, 4.0 KB (added by nacin, 3 years ago)

Fairly ambitious attempt to solve this. (Probably needs slash normalisation for Windows. I spell normalisation with an 's' to bribe dd32 to look.)

  • wp-admin/network.php

     
    310310        global $wpdb; 
    311311 
    312312        $hostname          = get_clean_basedomain(); 
    313         $slashed_home      = trailingslashit( get_option( 'home' ) ); 
     313        $home_path         = get_home_path(); 
     314 
     315        $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( ABSPATH, '#' ) . '#', '', $home_path ); // Will this work on Windows servers? 
    314316        $base              = parse_url( $slashed_home, PHP_URL_PATH ); 
    315         $wp_dir_from_root  = preg_replace( '#^' . preg_quote( $_SERVER['DOCUMENT_ROOT'], '#' ) . '#', '', ABSPATH ); 
    316         $wp_siteurl_subdir = trailingslashit( '/' . preg_replace( '#^' . preg_quote( $base, '#' ) . '#', '', $wp_dir_from_root ) ); 
    317317        $rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : ''; 
    318318 
     319        $location_of_wp_config = ABSPATH; 
     320        if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) 
     321                $location_of_wp_config = trailingslashit( dirname( ABSPATH ) ); 
     322 
    319323        // Wildcard DNS message. 
    320324        if ( is_wp_error( $errors ) ) 
    321325                echo '<div class="error">' . $errors->get_error_message() . '</div>'; 
     
    349353                <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3> 
    350354                <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p> 
    351355                <div class="updated inline"><p><?php 
    352                         if ( file_exists( ABSPATH . '.htaccess' ) ) 
     356                        if ( file_exists( $home_path . '.htaccess' ) ) 
    353357                                printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' ); 
    354                         elseif ( file_exists( ABSPATH . 'web.config' ) ) 
     358                        elseif ( file_exists( $home_path . 'web.config' ) ) 
    355359                                printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' ); 
    356360                        else 
    357361                                _e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' ); 
     
    360364        } 
    361365?> 
    362366                <ol> 
    363                         <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p> 
     367                        <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), $location_of_wp_config ); ?></p> 
    364368                                <textarea class="code" readonly="readonly" cols="100" rows="6"> 
    365369define('MULTISITE', true); 
    366370define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>); 
     
    454458EOF; 
    455459 
    456460        ?> 
    457                 <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), trailingslashit( str_replace( trailingslashit( $wp_siteurl_subdir ), '', ABSPATH ) ) ); ?></p> 
     461                <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p> 
    458462                <?php 
    459463                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) 
    460464                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>'; 
     
    488492EOF; 
    489493 
    490494                ?> 
    491                 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> 
     495                <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p> 
    492496                <?php 
    493497                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) 
    494498                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';