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.' ) . '

'; @@ -147,8 +153,9 @@ $error_codes = array(); if ( is_wp_error( $errors ) ) { echo '

' . __( 'ERROR: The network could not be created.' ) . '

'; - foreach ( $errors->get_error_messages() as $error ) + foreach ( $errors->get_error_messages() as $error ) { echo "

$error

"; + } echo '
'; $error_codes = $errors->get_error_codes(); } @@ -172,23 +179,25 @@ 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() ) { + } elseif ( ! allow_subdirectory_install() ) { $subdomain_install = true; } else { $subdomain_install = false; if ( $got_mod_rewrite = got_mod_rewrite() ) { // dangerous assumptions 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 '

'; } elseif ( $is_apache ) { 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 '

'; @@ -197,7 +206,8 @@ if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache) 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() ) : + ?>

- +
- + ); + ?> + - + ); + ?> + -

' . __( '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.' ) . '

'; + } $is_www = ( 0 === strpos( $hostname, 'www.' ) ); - if ( $is_www ) : + if ( $is_www ) : ?>

-

+ ' . substr( $hostname, 4 ) . '', '' . $hostname . '', 'www' - ); ?>

- + ); + ?> +

+
- -

- +
- + 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.' ) . ''; + } + ?> + - + - + ?> + - + - +