wp/wp-admin/includes/network.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    12  *
    12  *
    13  * @since 3.0.0
    13  * @since 3.0.0
    14  *
    14  *
    15  * @global wpdb $wpdb WordPress database abstraction object.
    15  * @global wpdb $wpdb WordPress database abstraction object.
    16  *
    16  *
    17  * @return Whether a network exists.
    17  * @return string|false Base domain if network exists, otherwise false.
    18  */
    18  */
    19 function network_domain_check() {
    19 function network_domain_check() {
    20 	global $wpdb;
    20 	global $wpdb;
    21 
    21 
    22 	$sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
    22 	$sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
    23 	if ( $wpdb->get_var( $sql ) ) {
    23 	if ( $wpdb->get_var( $sql ) ) {
    24 		return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
    24 		return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
    25 	}
    25 	}
    26 	return false;
    26 	return false;
    27 }
    27 }
    32  * @since 3.0.0
    32  * @since 3.0.0
    33  * @return bool Whether subdomain installation is allowed
    33  * @return bool Whether subdomain installation is allowed
    34  */
    34  */
    35 function allow_subdomain_install() {
    35 function allow_subdomain_install() {
    36 	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
    36 	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
    37 	if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
    37 	if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
    38 		return false;
    38 		return false;
       
    39 	}
    39 
    40 
    40 	return true;
    41 	return true;
    41 }
    42 }
    42 
    43 
    43 /**
    44 /**
    49  *
    50  *
    50  * @return bool Whether subdirectory installation is allowed
    51  * @return bool Whether subdirectory installation is allowed
    51  */
    52  */
    52 function allow_subdirectory_install() {
    53 function allow_subdirectory_install() {
    53 	global $wpdb;
    54 	global $wpdb;
    54         /**
    55 		/**
    55          * Filters whether to enable the subdirectory installation feature in Multisite.
    56 		 * Filters whether to enable the subdirectory installation feature in Multisite.
    56          *
    57 		 *
    57          * @since 3.0.0
    58 		 * @since 3.0.0
    58          *
    59 		 *
    59          * @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
    60 		 * @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
    60          */
    61 		 */
    61 	if ( apply_filters( 'allow_subdirectory_install', false ) )
    62 	if ( apply_filters( 'allow_subdirectory_install', false ) ) {
    62 		return true;
    63 		return true;
    63 
    64 	}
    64 	if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
    65 
       
    66 	if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
    65 		return true;
    67 		return true;
       
    68 	}
    66 
    69 
    67 	$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
    70 	$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
    68 	if ( empty( $post ) )
    71 	if ( empty( $post ) ) {
    69 		return true;
    72 		return true;
       
    73 	}
    70 
    74 
    71 	return false;
    75 	return false;
    72 }
    76 }
    73 
    77 
    74 /**
    78 /**
    76  *
    80  *
    77  * @since 3.0.0
    81  * @since 3.0.0
    78  * @return string Base domain.
    82  * @return string Base domain.
    79  */
    83  */
    80 function get_clean_basedomain() {
    84 function get_clean_basedomain() {
    81 	if ( $existing_domain = network_domain_check() )
    85 	if ( $existing_domain = network_domain_check() ) {
    82 		return $existing_domain;
    86 		return $existing_domain;
       
    87 	}
    83 	$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
    88 	$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
    84 	if ( $slash = strpos( $domain, '/' ) )
    89 	if ( $slash = strpos( $domain, '/' ) ) {
    85 		$domain = substr( $domain, 0, $slash );
    90 		$domain = substr( $domain, 0, $slash );
       
    91 	}
    86 	return $domain;
    92 	return $domain;
    87 }
    93 }
    88 
    94 
    89 /**
    95 /**
    90  * Prints step 1 for Network installation process.
    96  * Prints step 1 for Network installation process.
    91  *
    97  *
    92  * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
    98  * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
    93  * 	should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
    99  *  should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
    94  *
   100  *
    95  * @since 3.0.0
   101  * @since 3.0.0
    96  *
   102  *
    97  * @global bool $is_apache
   103  * @global bool $is_apache
    98  *
   104  *
    99  * @param WP_Error $errors
   105  * @param WP_Error $errors
   100  */
   106  */
   101 function network_step1( $errors = false ) {
   107 function network_step1( $errors = false ) {
   102 	global $is_apache;
   108 	global $is_apache;
   103 
   109 
   104 	if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
   110 	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
   105 		echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . sprintf(
   111 		echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . sprintf(
   106 			/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
   112 			/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
   107 			__( 'The constant %s cannot be defined when creating a network.' ),
   113 			__( 'The constant %s cannot be defined when creating a network.' ),
   108 			'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
   114 			'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
   109 		) . '</p></div>';
   115 		) . '</p></div>';
   123 		echo '</div>';
   129 		echo '</div>';
   124 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   130 		include( ABSPATH . 'wp-admin/admin-footer.php' );
   125 		die();
   131 		die();
   126 	}
   132 	}
   127 
   133 
   128 	$hostname = get_clean_basedomain();
   134 	$hostname  = get_clean_basedomain();
   129 	$has_ports = strstr( $hostname, ':' );
   135 	$has_ports = strstr( $hostname, ':' );
   130 	if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
   136 	if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
   131 		echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
   137 		echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
   132 		echo '<p>' . sprintf(
   138 		echo '<p>' . sprintf(
   133 			/* translators: %s: port number */
   139 			/* translators: %s: port number */
   145 	wp_nonce_field( 'install-network-1' );
   151 	wp_nonce_field( 'install-network-1' );
   146 
   152 
   147 	$error_codes = array();
   153 	$error_codes = array();
   148 	if ( is_wp_error( $errors ) ) {
   154 	if ( is_wp_error( $errors ) ) {
   149 		echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
   155 		echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
   150 		foreach ( $errors->get_error_messages() as $error )
   156 		foreach ( $errors->get_error_messages() as $error ) {
   151 			echo "<p>$error</p>";
   157 			echo "<p>$error</p>";
       
   158 		}
   152 		echo '</div>';
   159 		echo '</div>';
   153 		$error_codes = $errors->get_error_codes();
   160 		$error_codes = $errors->get_error_codes();
   154 	}
   161 	}
   155 
   162 
   156 	if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) {
   163 	if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) {
   170 	<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
   177 	<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
   171 	<?php
   178 	<?php
   172 
   179 
   173 	if ( isset( $_POST['subdomain_install'] ) ) {
   180 	if ( isset( $_POST['subdomain_install'] ) ) {
   174 		$subdomain_install = (bool) $_POST['subdomain_install'];
   181 		$subdomain_install = (bool) $_POST['subdomain_install'];
   175 	} elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
   182 	} elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // assume nothing
   176 		$subdomain_install = true;
   183 		$subdomain_install = true;
   177 	} elseif ( !allow_subdirectory_install() ) {
   184 	} elseif ( ! allow_subdirectory_install() ) {
   178 		$subdomain_install = true;
   185 		$subdomain_install = true;
   179 	} else {
   186 	} else {
   180 		$subdomain_install = false;
   187 		$subdomain_install = false;
   181 		if ( $got_mod_rewrite = got_mod_rewrite() ) { // dangerous assumptions
   188 		if ( $got_mod_rewrite = got_mod_rewrite() ) { // dangerous assumptions
   182 			echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
   189 			echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
   183 			/* translators: %s: mod_rewrite */
   190 			/* translators: %s: mod_rewrite */
   184 			printf( __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
   191 			printf(
       
   192 				__( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
   185 				'<code>mod_rewrite</code>'
   193 				'<code>mod_rewrite</code>'
   186 			);
   194 			);
   187 			echo '</p>';
   195 			echo '</p>';
   188 		} elseif ( $is_apache ) {
   196 		} elseif ( $is_apache ) {
   189 			echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
   197 			echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
   190 			/* translators: %s: mod_rewrite */
   198 			/* translators: %s: mod_rewrite */
   191 			printf( __( 'It looks like the Apache %s module is not installed.' ),
   199 			printf(
       
   200 				__( 'It looks like the Apache %s module is not installed.' ),
   192 				'<code>mod_rewrite</code>'
   201 				'<code>mod_rewrite</code>'
   193 			);
   202 			);
   194 			echo '</p>';
   203 			echo '</p>';
   195 		}
   204 		}
   196 
   205 
   197 		if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache)
   206 		if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache)
   198 			echo '<p>';
   207 			echo '<p>';
   199 			/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */
   208 			/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */
   200 			printf( __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
   209 			printf(
       
   210 				__( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
   201 				'<code>mod_rewrite</code>',
   211 				'<code>mod_rewrite</code>',
   202 				'https://httpd.apache.org/docs/mod/mod_rewrite.html',
   212 				'https://httpd.apache.org/docs/mod/mod_rewrite.html',
   203 				'https://www.google.com/search?q=apache+mod_rewrite'
   213 				'https://www.google.com/search?q=apache+mod_rewrite'
   204 			);
   214 			);
   205 			echo '</p></div>';
   215 			echo '</p></div>';
   206 		}
   216 		}
   207 	}
   217 	}
   208 
   218 
   209 	if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
   219 	if ( allow_subdomain_install() && allow_subdirectory_install() ) :
       
   220 		?>
   210 		<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
   221 		<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
   211 		<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
   222 		<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
   212 			<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
   223 			<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
   213 		<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
   224 		<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
   214 		<?php // @todo: Link to an MS readme? ?>
   225 		<?php // @todo: Link to an MS readme? ?>
   215 		<table class="form-table">
   226 		<table class="form-table" role="presentation">
   216 			<tr>
   227 			<tr>
   217 				<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
   228 				<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
   218 				<td><?php printf(
   229 				<td>
       
   230 				<?php
       
   231 				printf(
   219 					/* translators: 1: hostname */
   232 					/* translators: 1: hostname */
   220 					_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
   233 					_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
   221 					$hostname
   234 					$hostname
   222 				); ?></td>
   235 				);
       
   236 				?>
       
   237 				</td>
   223 			</tr>
   238 			</tr>
   224 			<tr>
   239 			<tr>
   225 				<th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
   240 				<th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
   226 				<td><?php printf(
   241 				<td>
       
   242 				<?php
       
   243 				printf(
   227 					/* translators: 1: hostname */
   244 					/* translators: 1: hostname */
   228 					_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
   245 					_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
   229 					$hostname
   246 					$hostname
   230 				); ?></td>
   247 				);
       
   248 				?>
       
   249 				</td>
   231 			</tr>
   250 			</tr>
   232 		</table>
   251 		</table>
   233 
   252 
   234 <?php
   253 		<?php
   235 	endif;
   254 	endif;
   236 
   255 
   237 		if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
   256 	if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
   238 			echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
   257 		echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
       
   258 	}
   239 
   259 
   240 		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
   260 		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
   241 		if ( $is_www ) :
   261 	if ( $is_www ) :
   242 		?>
   262 		?>
   243 		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
   263 		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
   244 		<p><?php printf(
   264 		<p>
   245 			/* translators: 1: site url 2: host name 3. www */
   265 		<?php
       
   266 		printf(
       
   267 			/* translators: 1: site url, 2: host name, 3: www */
   246 			__( 'We recommend you change your siteurl to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
   268 			__( 'We recommend you change your siteurl to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
   247 			'<code>' . substr( $hostname, 4 ) . '</code>',
   269 			'<code>' . substr( $hostname, 4 ) . '</code>',
   248 			'<code>' . $hostname . '</code>',
   270 			'<code>' . $hostname . '</code>',
   249 			'<code>www</code>'
   271 			'<code>www</code>'
   250 		); ?></p>
   272 		);
   251 		<table class="form-table">
   273 		?>
   252 			<tr>
   274 		</p>
   253 				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
   275 		<table class="form-table" role="presentation">
   254 				<td>
   276 			<tr>
   255 					<?php printf(
   277 			<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
       
   278 			<td>
       
   279 				<?php
       
   280 					printf(
   256 						/* translators: %s: host name */
   281 						/* translators: %s: host name */
   257 						__( 'The internet address of your network will be %s.' ),
   282 						__( 'The internet address of your network will be %s.' ),
   258 						'<code>' . $hostname . '</code>'
   283 						'<code>' . $hostname . '</code>'
   259 					); ?>
   284 					);
       
   285 				?>
   260 				</td>
   286 				</td>
   261 			</tr>
   287 			</tr>
   262 		</table>
   288 		</table>
   263 		<?php endif; ?>
   289 		<?php endif; ?>
   264 
   290 
   265 		<h3><?php esc_html_e( 'Network Details' ); ?></h3>
   291 		<h3><?php esc_html_e( 'Network Details' ); ?></h3>
   266 		<table class="form-table">
   292 		<table class="form-table" role="presentation">
   267 		<?php if ( 'localhost' == $hostname ) : ?>
   293 		<?php if ( 'localhost' == $hostname ) : ?>
   268 			<tr>
   294 			<tr>
   269 				<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
   295 				<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
   270 				<td><?php
   296 				<td>
       
   297 				<?php
   271 					printf(
   298 					printf(
   272 						/* translators: 1: localhost 2: localhost.localdomain */
   299 						/* translators: 1: localhost, 2: localhost.localdomain */
   273 						__( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
   300 						__( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
   274 						'<code>localhost</code>',
   301 						'<code>localhost</code>',
   275 						'<code>localhost.localdomain</code>'
   302 						'<code>localhost.localdomain</code>'
   276 					);
   303 					);
   277 					// Uh oh:
   304 					// Uh oh:
   278 					if ( !allow_subdirectory_install() )
   305 				if ( ! allow_subdirectory_install() ) {
   279 						echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
   306 					echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
   280 				?></td>
   307 				}
   281 			</tr>
   308 				?>
   282 		<?php elseif ( !allow_subdomain_install() ) : ?>
   309 				</td>
       
   310 			</tr>
       
   311 		<?php elseif ( ! allow_subdomain_install() ) : ?>
   283 			<tr>
   312 			<tr>
   284 				<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
   313 				<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
   285 				<td><?php
   314 				<td>
       
   315 				<?php
   286 					_e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
   316 					_e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
   287 					// Uh oh:
   317 					// Uh oh:
   288 					if ( !allow_subdirectory_install() )
   318 				if ( ! allow_subdirectory_install() ) {
   289 						echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
   319 					echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
   290 				?></td>
   320 				}
   291 			</tr>
   321 				?>
   292 		<?php elseif ( !allow_subdirectory_install() ) : ?>
   322 				</td>
       
   323 			</tr>
       
   324 		<?php elseif ( ! allow_subdirectory_install() ) : ?>
   293 			<tr>
   325 			<tr>
   294 				<th scope="row"><?php esc_html_e( 'Sub-domain Installation' ); ?></th>
   326 				<th scope="row"><?php esc_html_e( 'Sub-domain Installation' ); ?></th>
   295 				<td><?php _e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
   327 				<td>
       
   328 				<?php
       
   329 				_e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
   296 					echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
   330 					echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
   297 				?></td>
   331 				?>
       
   332 				</td>
   298 			</tr>
   333 			</tr>
   299 		<?php endif; ?>
   334 		<?php endif; ?>
   300 		<?php if ( ! $is_www ) : ?>
   335 		<?php if ( ! $is_www ) : ?>
   301 			<tr>
   336 			<tr>
   302 				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
   337 				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
   303 				<td>
   338 				<td>
   304 					<?php printf(
   339 					<?php
       
   340 					printf(
   305 						/* translators: %s: host name */
   341 						/* translators: %s: host name */
   306 						__( 'The internet address of your network will be %s.' ),
   342 						__( 'The internet address of your network will be %s.' ),
   307 						'<code>' . $hostname . '</code>'
   343 						'<code>' . $hostname . '</code>'
   308 					); ?>
   344 					);
       
   345 					?>
   309 				</td>
   346 				</td>
   310 			</tr>
   347 			</tr>
   311 		<?php endif; ?>
   348 		<?php endif; ?>
   312 			<tr>
   349 			<tr>
   313 				<th scope='row'><?php esc_html_e( 'Network Title' ); ?></th>
   350 				<th scope='row'><label for="sitename"><?php esc_html_e( 'Network Title' ); ?></label></th>
   314 				<td>
   351 				<td>
   315 					<input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
   352 					<input name='sitename' id='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
   316 					<p class="description">
   353 					<p class="description">
   317 						<?php _e( 'What would you like to call your network?' ); ?>
   354 						<?php _e( 'What would you like to call your network?' ); ?>
   318 					</p>
   355 					</p>
   319 				</td>
   356 				</td>
   320 			</tr>
   357 			</tr>
   321 			<tr>
   358 			<tr>
   322 				<th scope='row'><?php esc_html_e( 'Network Admin Email' ); ?></th>
   359 				<th scope='row'><label for="email"><?php esc_html_e( 'Network Admin Email' ); ?></label></th>
   323 				<td>
   360 				<td>
   324 					<input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
   361 					<input name='email' id='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
   325 					<p class="description">
   362 					<p class="description">
   326 						<?php _e( 'Your email address.' ); ?>
   363 						<?php _e( 'Your email address.' ); ?>
   327 					</p>
   364 					</p>
   328 				</td>
   365 				</td>
   329 			</tr>
   366 			</tr>
   352 	$abspath_fix       = str_replace( '\\', '/', ABSPATH );
   389 	$abspath_fix       = str_replace( '\\', '/', ABSPATH );
   353 	$home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
   390 	$home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
   354 	$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
   391 	$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
   355 	$rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
   392 	$rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
   356 
   393 
   357 
       
   358 	$location_of_wp_config = $abspath_fix;
   394 	$location_of_wp_config = $abspath_fix;
   359 	if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
   395 	if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
   360 		$location_of_wp_config = dirname( $abspath_fix );
   396 		$location_of_wp_config = dirname( $abspath_fix );
   361 	}
   397 	}
   362 	$location_of_wp_config = trailingslashit( $location_of_wp_config );
   398 	$location_of_wp_config = trailingslashit( $location_of_wp_config );
   363 
   399 
   364 	// Wildcard DNS message.
   400 	// Wildcard DNS message.
   365 	if ( is_wp_error( $errors ) )
   401 	if ( is_wp_error( $errors ) ) {
   366 		echo '<div class="error">' . $errors->get_error_message() . '</div>';
   402 		echo '<div class="error">' . $errors->get_error_message() . '</div>';
       
   403 	}
   367 
   404 
   368 	if ( $_POST ) {
   405 	if ( $_POST ) {
   369 		if ( allow_subdomain_install() )
   406 		if ( allow_subdomain_install() ) {
   370 			$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
   407 			$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
   371 		else
   408 		} else {
   372 			$subdomain_install = false;
   409 			$subdomain_install = false;
       
   410 		}
   373 	} else {
   411 	} else {
   374 		if ( is_multisite() ) {
   412 		if ( is_multisite() ) {
   375 			$subdomain_install = is_subdomain_install();
   413 			$subdomain_install = is_subdomain_install();
   376 ?>
   414 			?>
   377 	<p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
   415 	<p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
   378 <?php
   416 			<?php
   379 		} else {
   417 		} else {
   380 			$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
   418 			$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
   381 ?>
   419 			?>
   382 	<div class="error"><p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
   420 	<div class="error"><p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
   383 	<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>
   421 	<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>
   384 <?php
   422 			<?php
   385 		}
   423 		}
   386 	}
   424 	}
   387 
   425 
   388 	$subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
   426 	$subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
   389 	$subdir_replacement_01 = $subdomain_install ? '' : '$1';
   427 	$subdir_replacement_01 = $subdomain_install ? '' : '$1';
   390 	$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
   428 	$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
   391 
   429 
   392 	if ( $_POST || ! is_multisite() ) {
   430 	if ( $_POST || ! is_multisite() ) {
   393 ?>
   431 		?>
   394 		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
   432 		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
   395 		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
   433 		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
   396 		<div class="updated inline"><p><?php
   434 		<div class="updated inline"><p>
   397 			if ( file_exists( $home_path . '.htaccess' ) ) {
   435 		<?php
   398 				echo '<strong>' . __( 'Caution:' ) . '</strong> ';
   436 		if ( file_exists( $home_path . '.htaccess' ) ) {
   399 				printf(
   437 			echo '<strong>' . __( 'Caution:' ) . '</strong> ';
   400 					/* translators: 1: wp-config.php 2: .htaccess */
   438 			printf(
   401 					__( 'We recommend you back up your existing %1$s and %2$s files.' ),
   439 				/* translators: 1: wp-config.php, 2: .htaccess */
   402 					'<code>wp-config.php</code>',
   440 				__( 'We recommend you back up your existing %1$s and %2$s files.' ),
   403 					'<code>.htaccess</code>'
   441 				'<code>wp-config.php</code>',
   404 				);
   442 				'<code>.htaccess</code>'
   405 			} elseif ( file_exists( $home_path . 'web.config' ) ) {
   443 			);
   406 				echo '<strong>' . __( 'Caution:' ) . '</strong> ';
   444 		} elseif ( file_exists( $home_path . 'web.config' ) ) {
   407 				printf(
   445 			echo '<strong>' . __( 'Caution:' ) . '</strong> ';
   408 					/* translators: 1: wp-config.php 2: web.config */
   446 			printf(
   409 					__( 'We recommend you back up your existing %1$s and %2$s files.' ),
   447 				/* translators: 1: wp-config.php, 2: web.config */
   410 					'<code>wp-config.php</code>',
   448 				__( 'We recommend you back up your existing %1$s and %2$s files.' ),
   411 					'<code>web.config</code>'
   449 				'<code>wp-config.php</code>',
   412 				);
   450 				'<code>web.config</code>'
   413 			} else {
   451 			);
   414 				echo '<strong>' . __( 'Caution:' ) . '</strong> ';
   452 		} else {
   415 				printf(
   453 			echo '<strong>' . __( 'Caution:' ) . '</strong> ';
   416 					/* translators: 1: wp-config.php */
   454 			printf(
   417 					__( 'We recommend you back up your existing %s file.' ),
   455 				/* translators: %s: wp-config.php */
   418 					'<code>wp-config.php</code>'
   456 				__( 'We recommend you back up your existing %s file.' ),
   419 				);
   457 				'<code>wp-config.php</code>'
   420 			}
   458 			);
   421 		?></p></div>
   459 		}
   422 <?php
   460 		?>
   423 	}
   461 		</p></div>
   424 ?>
   462 		<?php
       
   463 	}
       
   464 	?>
   425 		<ol>
   465 		<ol>
   426 			<li><p><?php printf(
   466 			<li><p>
   427 				/* translators: 1: wp-config.php 2: location of wp-config file, 3: translated version of "That's all, stop editing! Happy blogging." */
   467 			<?php
       
   468 			printf(
       
   469 				/* translators: 1: wp-config.php, 2: location of wp-config file, 3: translated version of "That's all, stop editing! Happy publishing." */
   428 				__( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
   470 				__( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
   429 				'<code>wp-config.php</code>',
   471 				'<code>wp-config.php</code>',
   430 				'<code>' . $location_of_wp_config . '</code>',
   472 				'<code>' . $location_of_wp_config . '</code>',
   431 				/*
   473 				/*
   432 				 * translators: This string should only be translated if wp-config-sample.php is localized.
   474 				 * translators: This string should only be translated if wp-config-sample.php is localized.
   433 				 * You can check the localized release package or
   475 				 * You can check the localized release package or
   434 				 * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
   476 				 * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
   435 				 */
   477 				 */
   436 				'<code>/* ' . __( 'That&#8217;s all, stop editing! Happy blogging.' ) . ' */</code>'
   478 				'<code>/* ' . __( 'That&#8217;s all, stop editing! Happy publishing.' ) . ' */</code>'
   437 			); ?></p>
   479 			);
       
   480 			?>
       
   481 			</p>
   438 				<textarea class="code" readonly="readonly" cols="100" rows="7">
   482 				<textarea class="code" readonly="readonly" cols="100" rows="7">
   439 define('MULTISITE', true);
   483 define('MULTISITE', true);
   440 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
   484 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
   441 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
   485 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
   442 define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
   486 define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
   443 define('SITE_ID_CURRENT_SITE', 1);
   487 define('SITE_ID_CURRENT_SITE', 1);
   444 define('BLOG_ID_CURRENT_SITE', 1);
   488 define('BLOG_ID_CURRENT_SITE', 1);
   445 </textarea>
   489 </textarea>
   446 <?php
   490 	<?php
   447 	$keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
   491 	$keys_salts = array(
       
   492 		'AUTH_KEY'         => '',
       
   493 		'SECURE_AUTH_KEY'  => '',
       
   494 		'LOGGED_IN_KEY'    => '',
       
   495 		'NONCE_KEY'        => '',
       
   496 		'AUTH_SALT'        => '',
       
   497 		'SECURE_AUTH_SALT' => '',
       
   498 		'LOGGED_IN_SALT'   => '',
       
   499 		'NONCE_SALT'       => '',
       
   500 	);
   448 	foreach ( $keys_salts as $c => $v ) {
   501 	foreach ( $keys_salts as $c => $v ) {
   449 		if ( defined( $c ) )
   502 		if ( defined( $c ) ) {
   450 			unset( $keys_salts[ $c ] );
   503 			unset( $keys_salts[ $c ] );
       
   504 		}
   451 	}
   505 	}
   452 
   506 
   453 	if ( ! empty( $keys_salts ) ) {
   507 	if ( ! empty( $keys_salts ) ) {
   454 		$keys_salts_str = '';
   508 		$keys_salts_str = '';
   455 		$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
   509 		$from_api       = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
   456 		if ( is_wp_error( $from_api ) ) {
   510 		if ( is_wp_error( $from_api ) ) {
   457 			foreach ( $keys_salts as $c => $v ) {
   511 			foreach ( $keys_salts as $c => $v ) {
   458 				$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
   512 				$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
   459 			}
   513 			}
   460 		} else {
   514 		} else {
   462 			foreach ( $keys_salts as $c => $v ) {
   516 			foreach ( $keys_salts as $c => $v ) {
   463 				$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
   517 				$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
   464 			}
   518 			}
   465 		}
   519 		}
   466 		$num_keys_salts = count( $keys_salts );
   520 		$num_keys_salts = count( $keys_salts );
   467 ?>
   521 		?>
   468 	<p>
   522 <p>
   469 		<?php
   523 		<?php
   470 			if ( 1 == $num_keys_salts ) {
   524 		if ( 1 == $num_keys_salts ) {
   471 				printf(
   525 			printf(
   472 					/* translators: 1: wp-config.php */
   526 				/* translators: %s: wp-config.php */
   473 					__( 'This unique authentication key is also missing from your %s file.' ),
   527 				__( 'This unique authentication key is also missing from your %s file.' ),
   474 					'<code>wp-config.php</code>'
   528 				'<code>wp-config.php</code>'
   475 				);
   529 			);
   476 			} else {
   530 		} else {
   477 				printf(
   531 			printf(
   478 					/* translators: 1: wp-config.php */
   532 				/* translators: %s: wp-config.php */
   479 					__( 'These unique authentication keys are also missing from your %s file.' ),
   533 				__( 'These unique authentication keys are also missing from your %s file.' ),
   480 					'<code>wp-config.php</code>'
   534 				'<code>wp-config.php</code>'
   481 				);
   535 			);
   482 			}
   536 		}
   483 		?>
   537 		?>
   484 		<?php _e( 'To make your installation more secure, you should also add:' ); ?>
   538 		<?php _e( 'To make your installation more secure, you should also add:' ); ?>
   485 	</p>
   539 	</p>
   486 	<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
   540 	<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
   487 <?php
   541 		<?php
   488 	}
   542 	}
   489 ?>
   543 	?>
   490 </li>
   544 </li>
   491 <?php
   545 	<?php
   492 	if ( iis7_supports_permalinks() ) :
   546 	if ( iis7_supports_permalinks() ) :
   493 		// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
   547 		// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
   494 		$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
   548 		$iis_subdir_match       = ltrim( $base, '/' ) . $subdir_match;
   495 		$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
   549 		$iis_rewrite_base       = ltrim( $base, '/' ) . $rewrite_base;
   496 		$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
   550 		$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
   497 
   551 
   498 		$web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
   552 		$web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
   499 <configuration>
   553 <configuration>
   500     <system.webServer>
   554     <system.webServer>
   502             <rules>
   556             <rules>
   503                 <rule name="WordPress Rule 1" stopProcessing="true">
   557                 <rule name="WordPress Rule 1" stopProcessing="true">
   504                     <match url="^index\.php$" ignoreCase="false" />
   558                     <match url="^index\.php$" ignoreCase="false" />
   505                     <action type="None" />
   559                     <action type="None" />
   506                 </rule>';
   560                 </rule>';
   507 				if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
   561 		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
   508 					$web_config_file .= '
   562 			$web_config_file .= '
   509                 <rule name="WordPress Rule for Files" stopProcessing="true">
   563                 <rule name="WordPress Rule for Files" stopProcessing="true">
   510                     <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
   564                     <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
   511                     <action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
   565                     <action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
   512                 </rule>';
   566                 </rule>';
   513                 }
   567 		}
   514                 $web_config_file .= '
   568 			$web_config_file .= '
   515                 <rule name="WordPress Rule 2" stopProcessing="true">
   569                 <rule name="WordPress Rule 2" stopProcessing="true">
   516                     <match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
   570                     <match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
   517                     <action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
   571                     <action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
   518                 </rule>
   572                 </rule>
   519                 <rule name="WordPress Rule 3" stopProcessing="true">
   573                 <rule name="WordPress Rule 3" stopProcessing="true">
   540         </rewrite>
   594         </rewrite>
   541     </system.webServer>
   595     </system.webServer>
   542 </configuration>
   596 </configuration>
   543 ';
   597 ';
   544 
   598 
   545 		echo '<li><p>';
   599 			echo '<li><p>';
   546 		printf(
   600 			printf(
   547 			/* translators: 1: a filename like .htaccess. 2: a file path. */
   601 				/* translators: 1: a filename like .htaccess, 2: a file path */
   548 			__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
   602 				__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
   549 			'<code>web.config</code>',
   603 				'<code>web.config</code>',
   550 			'<code>' . $home_path . '</code>'
   604 				'<code>' . $home_path . '</code>'
   551 		);
   605 			);
   552 		echo '</p>';
   606 		echo '</p>';
   553 		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
   607 		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) {
   554 			echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
   608 			echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
   555 		?>
   609 		}
   556 		<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
   610 		?>
       
   611 	<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
   557 		</textarea></li>
   612 		</textarea></li>
   558 		</ol>
   613 		</ol>
   559 
   614 
   560 	<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
   615 		<?php
       
   616 	else : // end iis7_supports_permalinks(). construct an htaccess file instead:
   561 
   617 
   562 		$ms_files_rewriting = '';
   618 		$ms_files_rewriting = '';
   563 		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
   619 		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
   564 			$ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
   620 			$ms_files_rewriting  = "\n# uploaded files\nRewriteRule ^";
   565 			$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
   621 			$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
   566 		}
   622 		}
   567 
   623 
   568 		$htaccess_file = <<<EOF
   624 		$htaccess_file = <<<EOF
   569 RewriteEngine On
   625 RewriteEngine On
   582 
   638 
   583 EOF;
   639 EOF;
   584 
   640 
   585 		echo '<li><p>';
   641 		echo '<li><p>';
   586 		printf(
   642 		printf(
   587 			/* translators: 1: a filename like .htaccess. 2: a file path. */
   643 			/* translators: 1: a filename like .htaccess, 2: a file path */
   588 			__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
   644 			__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
   589 			'<code>.htaccess</code>',
   645 			'<code>.htaccess</code>',
   590 			'<code>' . $home_path . '</code>'
   646 			'<code>' . $home_path . '</code>'
   591 		);
   647 		);
   592 		echo '</p>';
   648 		echo '</p>';
   593 		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
   649 		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) {
   594 			echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
   650 			echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
       
   651 		}
   595 		?>
   652 		?>
   596 		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
   653 		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
   597 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
   654 		<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
   598 		</ol>
   655 		</ol>
   599 
   656 
   600 	<?php endif; // end IIS/Apache code branches.
   657 		<?php
   601 
   658 	endif; // end IIS/Apache code branches.
   602 	if ( !is_multisite() ) { ?>
   659 
       
   660 	if ( ! is_multisite() ) {
       
   661 		?>
   603 		<p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
   662 		<p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
   604 <?php
   663 		<?php
   605 	}
   664 	}
   606 }
   665 }