diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/network.php --- a/wp/wp-admin/includes/network.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/network.php Fri Sep 05 18:40:08 2025 +0200 @@ -33,8 +33,9 @@ * @return bool Whether subdomain installation 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 ) ) { + $home = get_option( 'home' ); + $domain = parse_url( $home, PHP_URL_HOST ); + if ( parse_url( $home, PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) { return false; } @@ -113,11 +114,20 @@ global $is_apache; if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { - echo '

' . __( 'Error:' ) . ' ' . sprintf( + $cannot_define_constant_message = '' . __( 'Error:' ) . ' '; + $cannot_define_constant_message .= sprintf( /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */ __( 'The constant %s cannot be defined when creating a network.' ), 'DO_NOT_UPGRADE_GLOBAL_TABLES' - ) . '

'; + ); + + wp_admin_notice( + $cannot_define_constant_message, + array( + 'additional_classes' => array( 'error' ), + ) + ); + echo ''; require_once ABSPATH . 'wp-admin/admin-footer.php'; die(); @@ -125,31 +135,22 @@ $active_plugins = get_option( 'active_plugins' ); if ( ! empty( $active_plugins ) ) { - echo '

' . __( 'Warning:' ) . ' ' . sprintf( - /* translators: %s: URL to Plugins screen. */ - __( 'Please deactivate your plugins before enabling the Network feature.' ), - admin_url( 'plugins.php?plugin_status=active' ) - ) . '

'; + wp_admin_notice( + '' . __( 'Warning:' ) . ' ' . sprintf( + /* translators: %s: URL to Plugins screen. */ + __( 'Please deactivate your plugins before enabling the Network feature.' ), + admin_url( 'plugins.php?plugin_status=active' ) + ), + array( 'type' => 'warning' ) + ); echo '

' . __( 'Once the network is created, you may reactivate your plugins.' ) . '

'; echo ''; 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' ), true ) ) ) { - echo '

' . __( 'Error:' ) . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

'; - echo '

' . sprintf( - /* translators: %s: Port number. */ - __( 'You cannot use port numbers such as %s.' ), - '' . $has_ports . '' - ) . '

'; - echo '' . __( 'Go to Dashboard' ) . ''; - echo ''; - require_once ABSPATH . 'wp-admin/admin-footer.php'; - die(); - } + // Strip standard port from hostname. + $hostname = preg_replace( '/(?::80|:443)$/', '', get_clean_basedomain() ); echo '
'; @@ -157,11 +158,17 @@ $error_codes = array(); if ( is_wp_error( $errors ) ) { - echo '

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

'; + $network_created_error_message = '

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

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

$error

"; + $network_created_error_message .= "

$error

"; } - echo '
'; + wp_admin_notice( + $network_created_error_message, + array( + 'additional_classes' => array( 'error' ), + 'paragraph_wrap' => false, + ) + ); $error_codes = $errors->get_error_codes(); } @@ -192,33 +199,39 @@ $subdomain_install = false; $got_mod_rewrite = got_mod_rewrite(); if ( $got_mod_rewrite ) { // Dangerous assumptions. - echo '

' . __( 'Note:' ) . ' '; - printf( + $message_class = 'updated'; + $message = '

' . __( 'Warning:' ) . ' '; + $message .= '

' . sprintf( /* translators: %s: mod_rewrite */ __( '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:' ) . ' '; - printf( + $message_class = 'error'; + $message = '

' . __( 'Warning:' ) . ' '; + $message .= sprintf( /* translators: %s: mod_rewrite */ __( 'It looks like the Apache %s module is not installed.' ), 'mod_rewrite' - ); - echo '

'; + ) . '

'; } if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache). - echo '

'; - printf( + $message .= '

' . sprintf( /* 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 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' + ) . '

'; + + wp_admin_notice( + $message, + array( + 'additional_classes' => array( $message_class, 'inline' ), + 'paragraph_wrap' => false, + ) ); - echo '

'; } } @@ -260,10 +273,17 @@ endif; 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.' ) . '

'; + $subdirectory_warning_message = '' . __( 'Warning:' ) . ' '; + $subdirectory_warning_message .= __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ); + wp_admin_notice( + $subdirectory_warning_message, + array( + 'additional_classes' => array( 'error', 'inline' ), + ) + ); } - $is_www = ( 0 === strpos( $hostname, 'www.' ) ); + $is_www = str_starts_with( $hostname, 'www.' ); if ( $is_www ) : ?>

@@ -394,7 +414,7 @@ $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(); + $home_path = str_starts_with( $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 ), '/' ) : ''; @@ -406,7 +426,12 @@ // Wildcard DNS message. if ( is_wp_error( $errors ) ) { - echo '
' . $errors->get_error_message() . '
'; + wp_admin_notice( + $errors->get_error_message(), + array( + 'additional_classes' => array( 'error' ), + ) + ); } if ( $_POST ) { @@ -423,8 +448,14 @@ get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); + + wp_admin_notice( + '' . __( 'Warning:' ) . ' ' . __( 'An existing WordPress network was detected.' ), + array( + 'additional_classes' => array( 'error' ), + ) + ); ?> -

-

' . __( 'Caution:' ) . ' '; + $notice_args = array( + 'type' => 'warning', + 'additional_classes' => array( 'inline' ), + ); + if ( file_exists( $home_path . '.htaccess' ) ) { - echo '' . __( 'Caution:' ) . ' '; - printf( + $notice_message .= sprintf( /* translators: 1: wp-config.php, 2: .htaccess */ __( 'You should back up your existing %1$s and %2$s files.' ), 'wp-config.php', '.htaccess' ); } elseif ( file_exists( $home_path . 'web.config' ) ) { - echo '' . __( 'Caution:' ) . ' '; - printf( + $notice_message .= sprintf( /* translators: 1: wp-config.php, 2: web.config */ __( 'You should back up your existing %1$s and %2$s files.' ), 'wp-config.php', 'web.config' ); } else { - echo '' . __( 'Caution:' ) . ' '; - printf( + $notice_message .= sprintf( /* translators: %s: wp-config.php */ __( 'You should back up your existing %s file.' ), 'wp-config.php' ); } - ?> -

-
    -
  1. +

  2. - +

    + @@ -603,7 +645,7 @@ '; - echo '
  3. '; + echo '

  4. '; printf( /* translators: 1: File name (.htaccess or web.config), 2: File path. */ __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ), @@ -615,7 +657,16 @@ echo '

    ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

    '; } ?> - +

    +
@@ -626,7 +677,7 @@ printf( /* translators: %s: Documentation URL. */ __( 'It seems your network is running with Nginx web server. Learn more about further configuration.' ), - __( 'https://wordpress.org/support/article/nginx/' ) + __( 'https://developer.wordpress.org/advanced-administration/server/web-server/nginx/' ) ); echo '

'; @@ -656,7 +707,7 @@ EOF; - echo '
  • '; + echo '

  • '; printf( /* translators: 1: File name (.htaccess or web.config), 2: File path. */ __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ), @@ -668,7 +719,16 @@ echo '

    ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

    '; } ?> - +

    +