<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[34023] trunk/src/wp-admin: Create `wp-admin/includes/network.php` via `svn cp` and only load it in `wp-admin/network.php`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/34023">34023</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/34023","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-09-10 22:00:58 +0000 (Thu, 10 Sep 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Create `wp-admin/includes/network.php` via `svn cp` and only load it in `wp-admin/network.php`. Move the functions there.
See <a href="https://core.trac.wordpress.org/ticket/33813">#33813</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminnetworkphp">trunk/src/wp-admin/network.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesnetworkphp">trunk/src/wp-admin/includes/network.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesnetworkphpfromrev34014trunksrcwpadminnetworkphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/src/wp-admin/includes/network.php (from rev 34014, trunk/src/wp-admin/network.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/network.php (rev 0)
+++ trunk/src/wp-admin/includes/network.php 2015-09-10 22:00:58 UTC (rev 34023)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,500 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WordPress Network Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 4.4.0
+ */
+
+/**
+ * Check for an existing network.
+ *
+ * @since 3.0.0
+ *
+ * @global wpdb $wpdb
+ *
+ * @return Whether a network exists.
+ */
+function network_domain_check() {
+ global $wpdb;
+
+ $sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
+ if ( $wpdb->get_var( $sql ) ) {
+ return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
+ }
+ return false;
+}
+
+/**
+ * Allow subdomain install
+ *
+ * @since 3.0.0
+ * @return bool Whether subdomain install is allowed
+ */
+function allow_subdomain_install() {
+ $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
+ if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
+ return false;
+
+ return true;
+}
+
+/**
+ * Allow subdirectory install.
+ *
+ * @since 3.0.0
+ *
+ * @global wpdb $wpdb
+ *
+ * @return bool Whether subdirectory install is allowed
+ */
+function allow_subdirectory_install() {
+ global $wpdb;
+ /**
+ * Filter whether to enable the subdirectory install feature in Multisite.
+ *
+ * @since 3.0.0
+ *
+ * @param bool true Whether to enable the subdirectory install feature in Multisite. Default is false.
+ */
+ if ( apply_filters( 'allow_subdirectory_install', false ) )
+ return true;
+
+ if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
+ return true;
+
+ $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
+ if ( empty( $post ) )
+ return true;
+
+ return false;
+}
+
+/**
+ * Get base domain of network.
+ *
+ * @since 3.0.0
+ * @return string Base domain.
+ */
+function get_clean_basedomain() {
+ if ( $existing_domain = network_domain_check() )
+ return $existing_domain;
+ $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
+ if ( $slash = strpos( $domain, '/' ) )
+ $domain = substr( $domain, 0, $slash );
+ return $domain;
+}
+
+/**
+ * Prints step 1 for Network installation process.
+ *
+ * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
+ * should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
+ *
+ * @since 3.0.0
+ *
+ * @global bool $is_apache
+ *
+ * @param WP_Error $errors
+ */
+function network_step1( $errors = false ) {
+ global $is_apache;
+
+ if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
+ echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
+ echo '</div>';
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
+ die();
+ }
+
+ $active_plugins = get_option( 'active_plugins' );
+ if ( ! empty( $active_plugins ) ) {
+ echo '<div class="updated"><p><strong>' . __('Warning:') . '</strong> ' . sprintf( __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '</p></div><p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
+ echo '</div>';
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
+ die();
+ }
+
+ $hostname = get_clean_basedomain();
+ $has_ports = strstr( $hostname, ':' );
+ if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
+ echo '<div class="error"><p><strong>' . __( 'ERROR:') . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
+ echo '<p>' . sprintf( __( 'You cannot use port numbers such as <code>%s</code>.' ), $has_ports ) . '</p>';
+ echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>';
+ echo '</div>';
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
+ die();
+ }
+
+ echo '<form method="post">';
+
+ wp_nonce_field( 'install-network-1' );
+
+ $error_codes = array();
+ if ( is_wp_error( $errors ) ) {
+ echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
+ foreach ( $errors->get_error_messages() as $error )
+ echo "<p>$error</p>";
+ echo '</div>';
+ $error_codes = $errors->get_error_codes();
+ }
+
+ $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
+ $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
+ ?>
+ <p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
+ <p><?php _e( 'Fill in the information below and you’ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
+ <?php
+
+ if ( isset( $_POST['subdomain_install'] ) ) {
+ $subdomain_install = (bool) $_POST['subdomain_install'];
+ } elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
+ $subdomain_install = true;
+ } elseif ( !allow_subdirectory_install() ) {
+ $subdomain_install = true;
+ } else {
+ $subdomain_install = false;
+ if ( $got_mod_rewrite = got_mod_rewrite() ) // dangerous assumptions
+ echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this installation.' ) . '</p>';
+ elseif ( $is_apache )
+ echo '<div class="error inline"><p><strong>' . __( 'Warning!' ) . '</strong> ' . __( 'It looks like the Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>';
+ if ( $got_mod_rewrite || $is_apache ) // Protect against mod_rewrite mimicry (but ! Apache)
+ echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
+ }
+
+ if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
+ <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
+ <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>
+ <p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
+ <?php // @todo: Link to an MS readme? ?>
+ <table class="form-table">
+ <tr>
+ <th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
+ <td><?php printf(
+ /* translators: 1: hostname */
+ _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
+ $hostname
+ ); ?></td>
+ </tr>
+ <tr>
+ <th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
+ <td><?php printf(
+ /* translators: 1: hostname */
+ _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
+ $hostname
+ ); ?></td>
+ </tr>
+ </table>
+
+<?php
+ 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 ); ?>' />
+ <p class="description">
+ <?php _e( 'What would you like to call your network?' ); ?>
+ </p>
+ </td>
+ </tr>
+ <tr>
+ <th scope='row'><?php esc_html_e( 'Network Admin Email' ); ?></th>
+ <td>
+ <input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
+ <p class="description">
+ <?php _e( 'Your email address.' ); ?>
+ </p>
+ </td>
+ </tr>
+ </table>
+ <?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
+ </form>
+ <?php
+}
+
+/**
+ * Prints step 2 for Network installation process.
+ *
+ * @since 3.0.0
+ *
+ * @global wpdb $wpdb
+ *
+ * @param WP_Error $errors
+ */
+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 );
+ $document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
+ $abspath_fix = str_replace( '\\', '/', ABSPATH );
+ $home_path = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
+ $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
+ $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
+
+
+ $location_of_wp_config = $abspath_fix;
+ if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
+ $location_of_wp_config = dirname( $abspath_fix );
+ }
+ $location_of_wp_config = trailingslashit( $location_of_wp_config );
+
+ // 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="7">
+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
+ if ( 1 == $num_keys_salts ) {
+ _e( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.' );
+ } else {
+ _e( 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.' );
+ }
+ ?>
+ <?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 = '<?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 . WPINC . '/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>
+';
+
+ echo '<li><p>';
+ /* translators: 1: a filename like .htaccess. 2: a file path. */
+ printf( __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
+ '<code>web.config</code>', '<code>' . $home_path . '</code>' );
+ echo '</p>';
+ 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}" . WPINC . "/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;
+
+ echo '<li><p>';
+ /* translators: 1: a filename like .htaccess. 2: a file path. */
+ printf( __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
+ '<code>.htaccess</code>', '<code>' . $home_path . '</code>' );
+ echo '</p>';
+ 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 _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( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
+<?php
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcwpadminnetworkphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/network.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/network.php 2015-09-10 21:44:29 UTC (rev 34022)
+++ trunk/src/wp-admin/network.php 2015-09-10 22:00:58 UTC (rev 34023)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,102 +15,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /** WordPress Administration Bootstrap */
</span><span class="cx" style="display: block; padding: 0 10px"> require_once( dirname( __FILE__ ) . '/admin.php' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( ! is_super_admin() )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( ! is_super_admin() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_network_admin() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_redirect( network_admin_url( 'setup.php' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! defined( 'MULTISITE' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( ! defined( 'MULTISITE' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require_once( dirname( __FILE__ ) . '/includes/network.php' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // We need to create references to ms global tables to enable Network.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $wpdb->$table = $prefixed_table;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-/**
- * Check for an existing network.
- *
- * @since 3.0.0
- *
- * @global wpdb $wpdb
- *
- * @return Whether a network exists.
- */
-function network_domain_check() {
- global $wpdb;
-
- $sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
- if ( $wpdb->get_var( $sql ) ) {
- return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
- }
- return false;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Allow subdomain install
- *
- * @since 3.0.0
- * @return bool Whether subdomain install is allowed
- */
-function allow_subdomain_install() {
- $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
- if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
- return false;
-
- return true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) ) {
+ wp_die( __( 'You must define the <code>WP_ALLOW_MULTISITE</code> constant as true in your wp-config.php file to allow creation of a Network.' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Allow subdirectory install.
- *
- * @since 3.0.0
- *
- * @global wpdb $wpdb
- *
- * @return bool Whether subdirectory install is allowed
- */
-function allow_subdirectory_install() {
- global $wpdb;
- /**
- * Filter whether to enable the subdirectory install feature in Multisite.
- *
- * @since 3.0.0
- *
- * @param bool true Whether to enable the subdirectory install feature in Multisite. Default is false.
- */
- if ( apply_filters( 'allow_subdirectory_install', false ) )
- return true;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
- return true;
-
- $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
- if ( empty( $post ) )
- return true;
-
- return false;
-}
-/**
- * Get base domain of network.
- *
- * @since 3.0.0
- * @return string Base domain.
- */
-function get_clean_basedomain() {
- if ( $existing_domain = network_domain_check() )
- return $existing_domain;
- $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
- if ( $slash = strpos( $domain, '/' ) )
- $domain = substr( $domain, 0, $slash );
- return $domain;
-}
-
-if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) )
- wp_die( __( 'You must define the <code>WP_ALLOW_MULTISITE</code> constant as true in your wp-config.php file to allow creation of a Network.' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_network_admin() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $title = __( 'Network Setup' );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_file = 'settings.php';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -148,419 +78,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <h1><?php echo esc_html( $title ); ?></h1>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Prints step 1 for Network installation process.
- *
- * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
- * should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
- *
- * @since 3.0.0
- *
- * @global bool $is_apache
- *
- * @param WP_Error $errors
- */
-function network_step1( $errors = false ) {
- global $is_apache;
-
- if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
- echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
- echo '</div>';
- include( ABSPATH . 'wp-admin/admin-footer.php' );
- die();
- }
-
- $active_plugins = get_option( 'active_plugins' );
- if ( ! empty( $active_plugins ) ) {
- echo '<div class="updated"><p><strong>' . __('Warning:') . '</strong> ' . sprintf( __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '</p></div><p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
- echo '</div>';
- include( ABSPATH . 'wp-admin/admin-footer.php' );
- die();
- }
-
- $hostname = get_clean_basedomain();
- $has_ports = strstr( $hostname, ':' );
- if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
- echo '<div class="error"><p><strong>' . __( 'ERROR:') . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
- echo '<p>' . sprintf( __( 'You cannot use port numbers such as <code>%s</code>.' ), $has_ports ) . '</p>';
- echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>';
- echo '</div>';
- include( ABSPATH . 'wp-admin/admin-footer.php' );
- die();
- }
-
- echo '<form method="post">';
-
- wp_nonce_field( 'install-network-1' );
-
- $error_codes = array();
- if ( is_wp_error( $errors ) ) {
- echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
- foreach ( $errors->get_error_messages() as $error )
- echo "<p>$error</p>";
- echo '</div>';
- $error_codes = $errors->get_error_codes();
- }
-
- $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
- $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
- ?>
- <p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
- <p><?php _e( 'Fill in the information below and you’ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
- <?php
-
- if ( isset( $_POST['subdomain_install'] ) ) {
- $subdomain_install = (bool) $_POST['subdomain_install'];
- } elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
- $subdomain_install = true;
- } elseif ( !allow_subdirectory_install() ) {
- $subdomain_install = true;
- } else {
- $subdomain_install = false;
- if ( $got_mod_rewrite = got_mod_rewrite() ) // dangerous assumptions
- echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this installation.' ) . '</p>';
- elseif ( $is_apache )
- echo '<div class="error inline"><p><strong>' . __( 'Warning!' ) . '</strong> ' . __( 'It looks like the Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>';
- if ( $got_mod_rewrite || $is_apache ) // Protect against mod_rewrite mimicry (but ! Apache)
- echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
- }
-
- if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
- <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
- <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>
- <p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
- <?php // @todo: Link to an MS readme? ?>
- <table class="form-table">
- <tr>
- <th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
- <td><?php printf(
- /* translators: 1: hostname */
- _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
- $hostname
- ); ?></td>
- </tr>
- <tr>
- <th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
- <td><?php printf(
- /* translators: 1: hostname */
- _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
- $hostname
- ); ?></td>
- </tr>
- </table>
-
-<?php
- 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 ); ?>' />
- <p class="description">
- <?php _e( 'What would you like to call your network?' ); ?>
- </p>
- </td>
- </tr>
- <tr>
- <th scope='row'><?php esc_html_e( 'Network Admin Email' ); ?></th>
- <td>
- <input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
- <p class="description">
- <?php _e( 'Your email address.' ); ?>
- </p>
- </td>
- </tr>
- </table>
- <?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
- </form>
- <?php
-}
-
-/**
- * Prints step 2 for Network installation process.
- *
- * @since 3.0.0
- *
- * @global wpdb $wpdb
- *
- * @param WP_Error $errors
- */
-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 );
- $document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
- $abspath_fix = str_replace( '\\', '/', ABSPATH );
- $home_path = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
- $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
- $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
-
-
- $location_of_wp_config = $abspath_fix;
- if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
- $location_of_wp_config = dirname( $abspath_fix );
- }
- $location_of_wp_config = trailingslashit( $location_of_wp_config );
-
- // 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="7">
-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
- if ( 1 == $num_keys_salts ) {
- _e( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.' );
- } else {
- _e( 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.' );
- }
- ?>
- <?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 = '<?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 . WPINC . '/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>
-';
-
- echo '<li><p>';
- /* translators: 1: a filename like .htaccess. 2: a file path. */
- printf( __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
- '<code>web.config</code>', '<code>' . $home_path . '</code>' );
- echo '</p>';
- 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}" . WPINC . "/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;
-
- echo '<li><p>';
- /* translators: 1: a filename like .htaccess. 2: a file path. */
- printf( __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
- '<code>.htaccess</code>', '<code>' . $home_path . '</code>' );
- echo '</p>';
- 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 _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( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
-<?php
- }
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $_POST ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer( 'install-network-1' );
</span></span></pre>
</div>
</div>
</body>
</html>