diff --git a/wp-admin/network/site-info.php b/wp-admin/network/site-info.php index a7c2a14a6c..38b1526a6f 100644 --- a/wp-admin/network/site-info.php +++ b/wp-admin/network/site-info.php @@ -46,7 +46,7 @@ if ( ! can_edit_network( $details->site_id ) ) { wp_die( __( 'You do not have permission to access this page.' ), 403 ); } -$parsed = parse_url( $details->siteurl ); +$parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME ); $is_main_site = is_main_site( $id ); if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) { @@ -57,8 +57,31 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) { // Rewrite rules can't be flushed during switch to blog. delete_option( 'rewrite_rules' ); - // Update blogs table. $blog_data = wp_unslash( $_POST['blog'] ); + + if ( $is_main_site ) { + // On the network's main site, don't allow the domain or path to change. + $blog_data['domain'] = $details->domain; + $blog_data['path'] = $details->path; + } elseif ( is_subdomain_install() ) { + // All parts of a URL can be updated for a subdomain configuration. We first + // need to ensure a scheme has been provided, otherwise fallback to the existing. + $new_url_scheme = parse_url( $blog_data['url'], PHP_URL_SCHEME ); + + if ( ! $new_url_scheme ) { + $blog_data['url'] = esc_url( $parsed_scheme . '://' . $blog_data['url'] ); + } + $update_parsed_url = parse_url( $blog_data['url'] ); + + $blog_data['scheme'] = $update_parsed_url['scheme']; + $blog_data['domain'] = $update_parsed_url['host']; + $blog_data['path'] = $update_parsed_url['path']; + } else { + // Only the path can be updated for a subdirectory configuration, so capture existing domain. + $blog_data['scheme'] = $parsed_scheme; + $blog_data['domain'] = $details->domain; + } + $existing_details = get_blog_details( $id, false ); $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' ); foreach ( $blog_data_checkboxes as $c ) { @@ -68,11 +91,12 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) { $blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0; } } + update_blog_details( $id, $blog_data ); if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { $new_details = get_blog_details( $id, false ); - $blog_address = esc_url_raw( $new_details->domain . $new_details->path ); + $blog_address = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) ); if ( get_option( 'siteurl' ) != $blog_address ) { update_option( 'siteurl', $blog_address ); } @@ -125,37 +149,53 @@ if ( ! empty( $messages ) ) { foreach ( $messages as $msg ) { echo '

' . $msg . '

'; } -} ?> +} + +switch_to_blog( $id ); +?>
+ + + + + + - - - - - - - + + + + + + + - - - - + + + + + + + - + + @@ -191,4 +231,5 @@ if ( ! empty( $messages ) ) {
siteurl ); ?>
domain ) ?>
domain ); ?>
path ) ?>
+
/>