WordPress.org

Make WordPress Core

Changeset 13000


Ignore:
Timestamp:
02/07/2010 02:13:20 AM (8 years ago)
Author:
wpmuguru
Message:

Allow network install to be restarted, see #11881

File:
1 edited

Legend:

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

    r12910 r13000  
    9797        wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) );
    9898    }
    99 
    100     //@todo: check for super-cache in use
    10199?>
    102100            <li><p><?php _e( 'Replace the contents of your <code>.htaccess</code> with the following:' ); ?></p>
     
    158156
    159157    wp_nonce_field( 'install-network-1' );
    160     ?>
     158    if ( network_domain_check() ) { ?>
     159        <h2><?php esc_html_e( 'Existing Sites' ); ?></h2>
     160        <p><?php _e( 'An existing WordPress Network was detected.' ); ?></p>
     161        <p class="existing-network">
     162            <label><input type='checkbox' name='existing_network' value='yes' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br />
     163        </p>
     164
     165<?php   } else { ?>
     166        <input type='hidden' name='existing_network' value='none' />
     167<?php   } ?>
    161168        <input type='hidden' name='action' value='step2' />
    162169        <h2><?php esc_html_e( 'Site Addresses' ); ?></h2>
     
    212219
    213220/**
     221 * Checks for active plugins & displays a notice to deactivate them.
     222 *
     223 * @since 3.0.0
     224 */
     225function step1_plugin_check() {
     226    $active_plugins = get_option( 'active_plugins' );
     227    if ( is_array( $active_plugins ) && !empty( $active_plugins ) ) {
     228?>
     229        <h2><?php esc_html_e( 'Enabling WordPress Sites' ); ?></h2>
     230        <p><?php printf( __( 'Please <a href="%s">deactivate</a> your plugins before enabling WordPress Sites. Once WordPress Sites are enabled, you may reactivate your plugins.' ), admin_url( 'plugins.php' ) ); ?></p>
     231<?php
     232        return false;
     233    }
     234    return true;
     235}
     236
     237/**
     238 * Checks for existing network data/tables.
     239 *
     240 * @since 3.0.0
     241 */
     242function network_domain_check() {
     243    global $wpdb;
     244
     245    if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) == $wpdb->site )
     246        return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
     247
     248    return false;
     249}
     250
     251/**
    214252 * Prints step 2 for network settings.
    215253 *
     
    309347function get_clean_basedomain() {
    310348    global $wpdb;
     349
     350    $existing_domain = network_domain_check();
     351    if ( $existing_domain )
     352        return $existing_domain;
     353
    311354    $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
    312355    if ( strpos( $domain, '/' ) )
     
    321364        check_admin_referer( 'install-network-1' );
    322365
    323         // Install!
    324         $base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
    325         if ( $base != '/' )
    326             $base .= '/';
    327 
    328         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    329         // create network tables
    330         $domain = get_clean_basedomain();
    331         install_network();
    332         populate_network( 1, $domain, sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
    333         // create wp-config.php / htaccess
    334         step2();
    335     break;
     366        if ( isset( $_POST[ 'existing_network' ] ) ) {
     367            // Install!
     368            $base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
     369            if ( $base != '/' )
     370                $base .= '/';
     371
     372            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     373            // create network tables
     374            $domain = get_clean_basedomain();
     375            install_network();
     376            if ( !network_domain_check() || $_POST[ 'existing_network' ] == 'none' )
     377                populate_network( 1, $domain, sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
     378            // create wp-config.php / htaccess
     379            step2();
     380            break;
     381        }
    336382    default:
    337383        //@todo: give an informative screen instead
    338384        if ( is_multisite() ) {
    339385            _e( 'Network already enabled.' );
    340         } else {
     386        } elseif ( step1_plugin_check() ) {
    341387            $rewrite_enabled = step1();
    342388            printstep1form( $rewrite_enabled );
Note: See TracChangeset for help on using the changeset viewer.