Remove the "Update siteurl and home as well" checkbox when editing a site
Rather than provide a checkbox to update the `siteurl` and `home` options, we can make an educated decision based on the current state. If the home and/or siteurl domain and path match the existing domain and path of the site, then we update with the new information. Also, while scheme is not stored in `wp_blogs` along with a site, the scheme of the `home` and `siteurl` options can now be modified via the Site URL setting in `site-info.php` when the `home` and/or `siteurl` options match the existing domain. Props @hugobaeta, @earnjam, @jeremyfelt. Fixes #32503, see #22383. git-svn-id: https://develop.svn.wordpress.org/trunk@32760 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
250aaa16e8
commit
4b0eaacd84
@ -58,6 +58,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
|
||||
delete_option( 'rewrite_rules' );
|
||||
|
||||
$blog_data = wp_unslash( $_POST['blog'] );
|
||||
$blog_data['scheme'] = $parsed_scheme;
|
||||
|
||||
if ( $is_main_site ) {
|
||||
// On the network's main site, don't allow the domain or path to change.
|
||||
@ -78,7 +79,6 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -94,15 +94,23 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
|
||||
|
||||
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 = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||
if ( get_option( 'siteurl' ) != $blog_address ) {
|
||||
update_option( 'siteurl', $blog_address );
|
||||
}
|
||||
if ( get_option( 'home' ) != $blog_address ) {
|
||||
update_option( 'home', $blog_address );
|
||||
}
|
||||
// Maybe update home and siteurl options.
|
||||
$new_details = get_blog_details( $id, false );
|
||||
|
||||
$old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
|
||||
$old_home_parsed = parse_url( $old_home_url );
|
||||
|
||||
if ( $old_home_parsed['host'] === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
|
||||
$new_home_url = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||
update_option( 'home', $new_home_url );
|
||||
}
|
||||
|
||||
$old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
|
||||
$old_site_parsed = parse_url( $old_site_url );
|
||||
|
||||
if ( $old_site_parsed['host'] === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
|
||||
$new_site_url = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||
update_option( 'siteurl', $new_site_url );
|
||||
}
|
||||
|
||||
restore_current_blog();
|
||||
@ -187,15 +195,6 @@ switch_to_blog( $id );
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! $is_main_site ) : ?>
|
||||
<tr class="form-field">
|
||||
<th scope="row"></th>
|
||||
<td>
|
||||
<input type="checkbox" name="update_home_url" id="update_home_url" value="update" <?php if ( get_option( 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_option( 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <label for="update_home_url"><?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="blog_registered"><?php _ex( 'Registered', 'site' ) ?></label></th>
|
||||
<td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" /></td>
|
||||
|
Loading…
Reference in New Issue
Block a user