diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/includes/network.php --- a/wp/wp-admin/includes/network.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-admin/includes/network.php Mon Oct 14 18:28:13 2019 +0200 @@ -14,12 +14,12 @@ * * @global wpdb $wpdb WordPress database abstraction object. * - * @return Whether a network exists. + * @return string|false Base domain if network exists, otherwise false. */ function network_domain_check() { global $wpdb; - $sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) ); + $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" ); } @@ -34,8 +34,9 @@ */ 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; + } return true; } @@ -51,22 +52,25 @@ */ 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. - */ - if ( apply_filters( 'allow_subdirectory_install', 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 is false. + */ + if ( apply_filters( 'allow_subdirectory_install', false ) ) { return true; + } - if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) + 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 ) ) + if ( empty( $post ) ) { return true; + } return false; } @@ -78,11 +82,13 @@ * @return string Base domain. */ function get_clean_basedomain() { - if ( $existing_domain = network_domain_check() ) + if ( $existing_domain = network_domain_check() ) { return $existing_domain; + } $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) ); - if ( $slash = strpos( $domain, '/' ) ) + if ( $slash = strpos( $domain, '/' ) ) { $domain = substr( $domain, 0, $slash ); + } return $domain; } @@ -90,7 +96,7 @@ * 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. + * 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 * @@ -101,7 +107,7 @@ function network_step1( $errors = false ) { global $is_apache; - if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { + if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { echo '
' . __( 'ERROR:' ) . ' ' . sprintf( /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */ __( 'The constant %s cannot be defined when creating a network.' ), @@ -125,7 +131,7 @@ die(); } - $hostname = get_clean_basedomain(); + $hostname = get_clean_basedomain(); $has_ports = strstr( $hostname, ':' ); if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) { echo '
' . __( 'ERROR:' ) . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '
' . __( 'ERROR: The network could not be created.' ) . '
'; - foreach ( $errors->get_error_messages() as $error ) + foreach ( $errors->get_error_messages() as $error ) { echo "$error
"; + } echo '' . __( 'Note:' ) . ' ';
/* translators: %s: mod_rewrite */
- printf( __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
+ printf(
+ __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
'mod_rewrite
'
);
echo '
' . __( 'Warning:' ) . ' ';
/* translators: %s: mod_rewrite */
- printf( __( 'It looks like the Apache %s module is not installed.' ),
+ printf(
+ __( 'It looks like the Apache %s module is not installed.' ),
'mod_rewrite
'
);
echo '
';
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */
- printf( __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ),
+ printf(
+ __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ),
'mod_rewrite
',
'https://httpd.apache.org/docs/mod/mod_rewrite.html',
'https://www.google.com/search?q=apache+mod_rewrite'
@@ -206,122 +216,149 @@
}
}
- if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
+ if ( allow_subdomain_install() && allow_subdirectory_install() ) :
+ ?>
-
- |
+ site1.%1$s and site2.%1$s ', 'subdomain examples' ),
$hostname
- ); ?> |
+ );
+ ?>
+
---|---|
- |
+ %1$s/site1 and %1$s/site2 ', 'subdirectory examples' ),
$hostname
- ); ?> |
+ );
+ ?>
+
' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '
'; + if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) { + echo '' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '
+ ' . substr( $hostname, 4 ) . '',
'' . $hostname . '
',
'www
'
- ); ?>
- | - + | + ' . $hostname . '' - ); ?> + ); + ?> |
---|
- |
+ localhost',
'localhost.localdomain '
);
// Uh oh:
- if ( !allow_subdirectory_install() )
- echo ' ' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '';
- ?> |
+ if ( ! allow_subdirectory_install() ) {
+ echo ' ' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '';
+ }
+ ?>
+
|
---|---|---|
- | + ' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . ''; - ?> | + if ( ! allow_subdirectory_install() ) { + echo ' ' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . ''; + } + ?> +|
- | + ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . ''; - ?> | + ?> +|
- ' . $hostname . '' - ); ?> + ); + ?> | ||
+ |
-
+
|
|
+ |
-
+
@@ -354,7 +391,6 @@ $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 ); @@ -362,26 +398,28 @@ $location_of_wp_config = trailingslashit( $location_of_wp_config ); // Wildcard DNS message. - if ( is_wp_error( $errors ) ) + if ( is_wp_error( $errors ) ) { echo ' ' . $errors->get_error_message() . ' ';
+ }
if ( $_POST ) {
- if ( allow_subdomain_install() )
+ if ( allow_subdomain_install() ) {
$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
- else
+ } else {
$subdomain_install = false;
+ }
} else {
if ( is_multisite() ) {
$subdomain_install = is_subdomain_install();
-?>
+ ?>
-get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
-?>
+ ?>
' . __( 'Caution:' ) . ' ';
- printf(
- /* translators: 1: wp-config.php 2: .htaccess */
- __( 'We recommend you back up your existing %1$s and %2$s files.' ),
- '
+ ' . __( 'Caution:' ) . ' ';
+ printf(
+ /* translators: 1: wp-config.php, 2: .htaccess */
+ __( 'We recommend you back up your existing %1$s and %2$s files.' ),
+ '
';
printf(
- /* translators: 1: a filename like .htaccess. 2: a file path. */
+ /* translators: 1: a filename like .htaccess, 2: a file path */
__( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ),
' ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . ' '; + } ?> |