--- a/wp/wp-admin/includes/network.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/network.php Tue Dec 15 13:49:49 2020 +0100
@@ -34,7 +34,7 @@
*/
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 ) ) {
+ if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
return false;
}
@@ -52,13 +52,15 @@
*/
function allow_subdirectory_install() {
global $wpdb;
- /**
- * Filters whether to enable the subdirectory installation feature in Multisite.
- *
- * @since 3.0.0
- *
- * @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
- */
+
+ /**
+ * Filters whether to enable the subdirectory installation feature in Multisite.
+ *
+ * @since 3.0.0
+ *
+ * @param bool $allow Whether to enable the subdirectory installation feature in Multisite.
+ * Default false.
+ */
if ( apply_filters( 'allow_subdirectory_install', false ) ) {
return true;
}
@@ -82,11 +84,13 @@
* @return string Base domain.
*/
function get_clean_basedomain() {
- if ( $existing_domain = network_domain_check() ) {
+ $existing_domain = network_domain_check();
+ if ( $existing_domain ) {
return $existing_domain;
}
$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
- if ( $slash = strpos( $domain, '/' ) ) {
+ $slash = strpos( $domain, '/' );
+ if ( $slash ) {
$domain = substr( $domain, 0, $slash );
}
return $domain;
@@ -95,8 +99,9 @@
/**
* 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.
+ * @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
*
@@ -108,41 +113,41 @@
global $is_apache;
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
- echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . sprintf(
+ echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . sprintf(
/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
__( 'The constant %s cannot be defined when creating a network.' ),
'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
) . '</p></div>';
echo '</div>';
- include( ABSPATH . 'wp-admin/admin-footer.php' );
+ require_once 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(
- /* translators: %s: Plugins screen URL */
+ echo '<div class="notice notice-warning"><p><strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
+ /* translators: %s: URL to Plugins screen. */
__( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
admin_url( 'plugins.php?plugin_status=active' )
) . '</p></div>';
echo '<p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
echo '</div>';
- include( ABSPATH . 'wp-admin/admin-footer.php' );
+ require_once 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>';
+ if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
+ echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
echo '<p>' . sprintf(
- /* translators: %s: port number */
+ /* translators: %s: Port number. */
__( 'You cannot use port numbers such as %s.' ),
'<code>' . $has_ports . '</code>'
) . '</p>';
echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>';
echo '</div>';
- include( ABSPATH . 'wp-admin/admin-footer.php' );
+ require_once ABSPATH . 'wp-admin/admin-footer.php';
die();
}
@@ -152,7 +157,7 @@
$error_codes = array();
if ( is_wp_error( $errors ) ) {
- echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
+ 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>";
}
@@ -160,14 +165,14 @@
$error_codes = $errors->get_error_codes();
}
- if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) {
+ if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes, true ) ) {
$site_name = $_POST['sitename'];
} else {
- /* translators: %s: Default network name */
+ /* translators: %s: Default network title. */
$site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) );
}
- if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) {
+ if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes, true ) ) {
$admin_email = $_POST['email'];
} else {
$admin_email = get_option( 'admin_email' );
@@ -179,34 +184,35 @@
if ( isset( $_POST['subdomain_install'] ) ) {
$subdomain_install = (bool) $_POST['subdomain_install'];
- } elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // assume nothing
+ } 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
+ $got_mod_rewrite = got_mod_rewrite();
+ if ( $got_mod_rewrite ) { // Dangerous assumptions.
echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
- /* translators: %s: mod_rewrite */
printf(
+ /* translators: %s: mod_rewrite */
__( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
'<code>mod_rewrite</code>'
);
echo '</p>';
} elseif ( $is_apache ) {
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
- /* translators: %s: mod_rewrite */
printf(
+ /* translators: %s: mod_rewrite */
__( 'It looks like the Apache %s module is not installed.' ),
'<code>mod_rewrite</code>'
);
echo '</p>';
}
- if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache)
+ if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
echo '<p>';
- /* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */
printf(
+ /* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
__( '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.' ),
'<code>mod_rewrite</code>',
'https://httpd.apache.org/docs/mod/mod_rewrite.html',
@@ -222,14 +228,14 @@
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
<strong><?php _e( '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? ?>
+ <?php // @todo Link to an MS readme? ?>
<table class="form-table" role="presentation">
<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 */
+ /* translators: 1: Host name. */
_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
$hostname
);
@@ -241,7 +247,7 @@
<td>
<?php
printf(
- /* translators: 1: hostname */
+ /* translators: 1: Host name. */
_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
$hostname
);
@@ -253,19 +259,19 @@
<?php
endif;
- if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
+ 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.' ) );
+ $is_www = ( 0 === strpos( $hostname, 'www.' ) );
if ( $is_www ) :
?>
<h3><?php esc_html_e( 'Server Address' ); ?></h3>
<p>
<?php
printf(
- /* translators: 1: site url, 2: host name, 3: www */
- __( '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.' ),
+ /* translators: 1: Site URL, 2: Host name, 3: www. */
+ __( 'We recommend you change your site domain 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.' ),
'<code>' . substr( $hostname, 4 ) . '</code>',
'<code>' . $hostname . '</code>',
'<code>www</code>'
@@ -278,7 +284,7 @@
<td>
<?php
printf(
- /* translators: %s: host name */
+ /* translators: %s: Host name. */
__( 'The internet address of your network will be %s.' ),
'<code>' . $hostname . '</code>'
);
@@ -290,7 +296,7 @@
<h3><?php esc_html_e( 'Network Details' ); ?></h3>
<table class="form-table" role="presentation">
- <?php if ( 'localhost' == $hostname ) : ?>
+ <?php if ( 'localhost' === $hostname ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
<td>
@@ -338,7 +344,7 @@
<td>
<?php
printf(
- /* translators: %s: host name */
+ /* translators: %s: Host name. */
__( 'The internet address of your network will be %s.' ),
'<code>' . $hostname . '</code>'
);
@@ -375,12 +381,13 @@
*
* @since 3.0.0
*
- * @global wpdb $wpdb WordPress database abstraction object.
+ * @global wpdb $wpdb WordPress database abstraction object.
+ * @global bool $is_nginx Whether the server software is Nginx or something else.
*
* @param WP_Error $errors
*/
function network_step2( $errors = false ) {
- global $wpdb;
+ global $wpdb, $is_nginx;
$hostname = get_clean_basedomain();
$slashed_home = trailingslashit( get_option( 'home' ) );
@@ -431,7 +438,7 @@
?>
<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>
+ <div class="notice notice-warning inline"><p>
<?php
if ( file_exists( $home_path . '.htaccess' ) ) {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
@@ -462,24 +469,24 @@
<?php
}
?>
- <ol>
- <li><p>
- <?php
- printf(
- /* translators: 1: wp-config.php, 2: location of wp-config file, 3: translated version of "That's all, stop editing! Happy publishing." */
- __( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
- '<code>wp-config.php</code>',
- '<code>' . $location_of_wp_config . '</code>',
- /*
- * translators: This string should only be translated if wp-config-sample.php is localized.
- * You can check the localized release package or
- * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
- */
- '<code>/* ' . __( 'That’s all, stop editing! Happy publishing.' ) . ' */</code>'
- );
- ?>
- </p>
- <textarea class="code" readonly="readonly" cols="100" rows="7">
+ <ol>
+ <li><p>
+ <?php
+ printf(
+ /* translators: 1: wp-config.php, 2: Location of wp-config file, 3: Translated version of "That's all, stop editing! Happy publishing." */
+ __( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
+ '<code>wp-config.php</code>',
+ '<code>' . $location_of_wp_config . '</code>',
+ /*
+ * translators: This string should only be translated if wp-config-sample.php is localized.
+ * You can check the localized release package or
+ * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
+ */
+ '<code>/* ' . __( 'That’s all, stop editing! Happy publishing.' ) . ' */</code>'
+ );
+ ?>
+ </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; ?>');
@@ -487,64 +494,64 @@
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 ) . "' );";
+ <?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 ] );
}
}
- $num_keys_salts = count( $keys_salts );
- ?>
-<p>
- <?php
- if ( 1 == $num_keys_salts ) {
- printf(
- /* translators: %s: wp-config.php */
- __( 'This unique authentication key is also missing from your %s file.' ),
- '<code>wp-config.php</code>'
- );
- } else {
- printf(
- /* translators: %s: wp-config.php */
- __( 'These unique authentication keys are also missing from your %s file.' ),
- '<code>wp-config.php</code>'
- );
+
+ 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 ) {
+ printf(
+ /* translators: %s: wp-config.php */
+ __( 'This unique authentication key is also missing from your %s file.' ),
+ '<code>wp-config.php</code>'
+ );
+ } else {
+ printf(
+ /* translators: %s: wp-config.php */
+ __( 'These unique authentication keys are also missing from your %s file.' ),
+ '<code>wp-config.php</code>'
+ );
+ }
+ ?>
+ <?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
}
?>
- <?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>
+ </li>
<?php
if ( iis7_supports_permalinks() ) :
- // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
+ // 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}';
@@ -598,22 +605,32 @@
echo '<li><p>';
printf(
- /* translators: 1: a filename like .htaccess, 2: a file path */
+ /* translators: 1: File name (.htaccess or web.config), 2: File path. */
__( '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' ) {
+ 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>
+ <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:
+ elseif ( $is_nginx ) : // End iis7_supports_permalinks(). Link to Nginx documentation instead:
+
+ echo '<li><p>';
+ printf(
+ /* translators: %s: Documentation URL. */
+ __( 'It seems your network is running with Nginx web server. <a href="%s">Learn more about further configuration</a>.' ),
+ __( 'https://wordpress.org/support/article/nginx/' )
+ );
+ echo '</p></li>';
+
+ else : // End $is_nginx. Construct an .htaccess file instead:
$ms_files_rewriting = '';
if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
@@ -640,22 +657,22 @@
echo '<li><p>';
printf(
- /* translators: 1: a filename like .htaccess, 2: a file path */
+ /* translators: 1: File name (.htaccess or web.config), 2: File path. */
__( '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' ) {
+ 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>
+ <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.
+ endif; // End IIS/Nginx/Apache code branches.
if ( ! is_multisite() ) {
?>