- endif;
-
- if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
- echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
-
- $is_www = ( 0 === strpos( $hostname, 'www.' ) );
- if ( $is_www ) :
- ?>
- <h3><?php esc_html_e( 'Server Address' ); ?></h3>
- <p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the <code>www</code> prefix with an address like <code>%2$s</code> but any links will not have the <code>www</code> prefix.' ), substr( $hostname, 4 ), $hostname ); ?></p>
- <table class="form-table">
- <tr>
- <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
- <td>
- <?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
- </td>
- </tr>
- </table>
- <?php endif; ?>
-
- <h3><?php esc_html_e( 'Network Details' ); ?></h3>
- <table class="form-table">
- <?php if ( 'localhost' == $hostname ) : ?>
- <tr>
- <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
- <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.' );
- // Uh oh:
- if ( !allow_subdirectory_install() )
- echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
- ?></td>
- </tr>
- <?php elseif ( !allow_subdomain_install() ) : ?>
- <tr>
- <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
- <td><?php
- _e( 'Because your install is in a directory, the sites in your WordPress network must use sub-directories.' );
- // Uh oh:
- if ( !allow_subdirectory_install() )
- echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
- ?></td>
- </tr>
- <?php elseif ( !allow_subdirectory_install() ) : ?>
- <tr>
- <th scope="row"><?php esc_html_e( 'Sub-domain Install' ); ?></th>
- <td><?php _e( 'Because your install is not new, the sites in your WordPress network must use sub-domains.' );
- echo ' <strong>' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
- ?></td>
- </tr>
- <?php endif; ?>
- <?php if ( ! $is_www ) : ?>
- <tr>
- <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
- <td>
- <?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
- </td>
- </tr>
- <?php endif; ?>
- <tr>
- <th scope='row'><?php esc_html_e( 'Network Title' ); ?></th>
- <td>
- <input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
- <br /><?php _e( 'What would you like to call your network?' ); ?>
- </td>
- </tr>
- <tr>
- <th scope='row'><?php esc_html_e( 'Admin E-mail Address' ); ?></th>
- <td>
- <input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
- <br /><?php _e( 'Your email address.' ); ?>
- </td>
- </tr>
- </table>
- <?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
- </form>
- <?php
-}
-
-/**
- * Prints step 2 for Network installation process.
- *
- * @since 3.0.0
- */
-function network_step2( $errors = false ) {
- global $wpdb;
-
- $hostname = get_clean_basedomain();
- $slashed_home = trailingslashit( get_option( 'home' ) );
- $base = parse_url( $slashed_home, PHP_URL_PATH );
- $wp_dir_from_root = preg_replace( '#^' . preg_quote( $_SERVER['DOCUMENT_ROOT'], '#' ) . '#', '', ABSPATH );
- $wp_siteurl_subdir = trailingslashit( '/' . preg_replace( '#^' . preg_quote( $base, '#' ) . '#', '', $wp_dir_from_root ) );
- $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
-
- $home_path = get_home_path();
-
- $location_of_wp_config = ABSPATH;
- if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) )
- $location_of_wp_config = trailingslashit( dirname( ABSPATH ) );
-
- // Wildcard DNS message.
- if ( is_wp_error( $errors ) )
- echo '<div class="error">' . $errors->get_error_message() . '</div>';
-
- if ( $_POST ) {
- if ( allow_subdomain_install() )
- $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
- else
- $subdomain_install = false;
- } else {
- if ( is_multisite() ) {
- $subdomain_install = is_subdomain_install();
-?>
- <p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
-<?php
- } else {
- $subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
-?>
- <div class="error"><p><strong><?php _e('Warning:'); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
- <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>
-<?php
- }
- }
-
- $subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
- $subdir_replacement_01 = $subdomain_install ? '' : '$1';
- $subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
-
- if ( $_POST || ! is_multisite() ) {
-?>
- <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
- <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
- <div class="updated inline"><p><?php
- if ( file_exists( $home_path . '.htaccess' ) )
- printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' );
- elseif ( file_exists( $home_path . 'web.config' ) )
- printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' );
- else
- _e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' );
- ?></p></div>
-<?php
- }
-?>
- <ol>
- <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’s all, stop editing! Happy blogging. */</code>:' ), $location_of_wp_config ); ?></p>
- <textarea class="code" readonly="readonly" cols="100" rows="6">
-define('MULTISITE', true);
-define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
-define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
-define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
-define('SITE_ID_CURRENT_SITE', 1);
-define('BLOG_ID_CURRENT_SITE', 1);
-</textarea>
-<?php
- $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
- foreach ( $keys_salts as $c => $v ) {
- if ( defined( $c ) )
- unset( $keys_salts[ $c ] );
- }
-
- if ( ! empty( $keys_salts ) ) {
- $keys_salts_str = '';
- $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
- if ( is_wp_error( $from_api ) ) {
- foreach ( $keys_salts as $c => $v ) {
- $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
- }
- } else {
- $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
- foreach ( $keys_salts as $c => $v ) {
- $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
- }
- }
- $num_keys_salts = count( $keys_salts );
-?>
- <p><?php
- echo _n( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts ); ?> <?php _e( 'To make your installation more secure, you should also add:' ) ?></p>
- <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
-<?php
- }
-?>
-</li>
-<?php
- if ( iis7_supports_permalinks() ) :
- // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
- $iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
- $iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
- $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
-
- $web_config_file = <<<EOF
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="WordPress Rule 1" stopProcessing="true">
- <match url="^index\.php$" ignoreCase="false" />
- <action type="None" />
- </rule>';
- if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
- $web_config_file .= '
- <rule name="WordPress Rule for Files" stopProcessing="true">
- <match url="^{$iis_subdir_match}files/(.+)" ignoreCase="false" />
- <action type="Rewrite" url="{$iis_rewrite_base}wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
- </rule>';
- }
- $web_config_file .= '
- <rule name="WordPress Rule 2" stopProcessing="true">
- <match url="^{$iis_subdir_match}wp-admin$" ignoreCase="false" />
- <action type="Redirect" url="{$iis_subdir_replacement}wp-admin/" redirectType="Permanent" />
- </rule>
- <rule name="WordPress Rule 3" stopProcessing="true">
- <match url="^" ignoreCase="false" />
- <conditions logicalGrouping="MatchAny">
- <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
- <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
- </conditions>
- <action type="None" />
- </rule>
- <rule name="WordPress Rule 4" stopProcessing="true">
- <match url="^{$iis_subdir_match}(wp-(content|admin|includes).*)" ignoreCase="false" />
- <action type="Rewrite" url="{$iis_rewrite_base}{R:1}" />
- </rule>
- <rule name="WordPress Rule 5" stopProcessing="true">
- <match url="^{$iis_subdir_match}([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
- <action type="Rewrite" url="{$iis_rewrite_base}{R:2}" />
- </rule>
- <rule name="WordPress Rule 6" stopProcessing="true">
- <match url="." ignoreCase="false" />
- <action type="Rewrite" url="index.php" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
-</configuration>
-EOF;
-
- ?>
- <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>
- <?php
- if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
- echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
- ?>
- <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
- </textarea></li>
- </ol>
-
- <?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
-
- $ms_files_rewriting = '';
- if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
- $ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
- $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}wp-includes/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
- }
-
- $htaccess_file = <<<EOF
-RewriteEngine On
-RewriteBase {$base}
-RewriteRule ^index\.php$ - [L]
-{$ms_files_rewriting}
-# add a trailing slash to /wp-admin
-RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement_01}wp-admin/ [R=301,L]
-
-RewriteCond %{REQUEST_FILENAME} -f [OR]
-RewriteCond %{REQUEST_FILENAME} -d
-RewriteRule ^ - [L]
-RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L]
-RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$subdir_replacement_12 [L]
-RewriteRule . index.php [L]
-EOF;
-
- ?>
- <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p>
- <?php
- if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
- echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
- ?>
- <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
-<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
- </ol>
-
- <?php endif; // end IIS/Apache code branches.
-
- if ( !is_multisite() ) { ?>
- <p><?php printf( __( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.') ); ?> <a href="<?php echo esc_url( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
-<?php
- }
-}
-