Changeset 32759 for trunk/src/wp-admin/network/site-info.php
- Timestamp:
- 06/14/2015 07:08:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/network/site-info.php
r32758 r32759 47 47 } 48 48 49 $parsed = parse_url( $details->siteurl);49 $parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME ); 50 50 $is_main_site = is_main_site( $id ); 51 51 … … 58 58 delete_option( 'rewrite_rules' ); 59 59 60 // Update blogs table.61 60 $blog_data = wp_unslash( $_POST['blog'] ); 61 62 if ( $is_main_site ) { 63 // On the network's main site, don't allow the domain or path to change. 64 $blog_data['domain'] = $details->domain; 65 $blog_data['path'] = $details->path; 66 } elseif ( is_subdomain_install() ) { 67 // All parts of a URL can be updated for a subdomain configuration. We first 68 // need to ensure a scheme has been provided, otherwise fallback to the existing. 69 $new_url_scheme = parse_url( $blog_data['url'], PHP_URL_SCHEME ); 70 71 if ( ! $new_url_scheme ) { 72 $blog_data['url'] = esc_url( $parsed_scheme . '://' . $blog_data['url'] ); 73 } 74 $update_parsed_url = parse_url( $blog_data['url'] ); 75 76 $blog_data['scheme'] = $update_parsed_url['scheme']; 77 $blog_data['domain'] = $update_parsed_url['host']; 78 $blog_data['path'] = $update_parsed_url['path']; 79 } else { 80 // Only the path can be updated for a subdirectory configuration, so capture existing domain. 81 $blog_data['scheme'] = $parsed_scheme; 82 $blog_data['domain'] = $details->domain; 83 } 84 62 85 $existing_details = get_blog_details( $id, false ); 63 86 $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' ); … … 69 92 } 70 93 } 94 71 95 update_blog_details( $id, $blog_data ); 72 96 73 97 if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { 74 98 $new_details = get_blog_details( $id, false ); 75 $blog_address = esc_url_raw( $new_details->domain . $new_details->path);99 $blog_address = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) ); 76 100 if ( get_option( 'siteurl' ) != $blog_address ) { 77 101 update_option( 'siteurl', $blog_address ); … … 126 150 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; 127 151 } 128 } ?> 152 } 153 154 switch_to_blog( $id ); 155 ?> 129 156 <form method="post" action="site-info.php?action=update-site"> 130 157 <?php wp_nonce_field( 'edit-site' ); ?> 131 158 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> 132 159 <table class="form-table"> 160 <?php 161 // The main site of the network should not be updated on this page. 162 if ( $is_main_site ) : ?> 163 <tr class="form-field"> 164 <th scope="row"><?php _e( 'Site URL' ); ?></th> 165 <td><?php echo esc_url( $details->siteurl ); ?></td> 166 </tr> 167 <?php 168 // In a subdomain configuration, the scheme, domain, and path can all be changed. 169 elseif ( is_subdomain_install() ) : ?> 133 170 <tr class="form-field form-required"> 134 <?php if ( $is_main_site ) { ?> 135 <th scope="row"><?php _e( 'Domain' ) ?></th> 136 <td><code><?php echo $parsed['scheme'] . '://' . esc_attr( $details->domain ) ?></code></td> 137 <?php } else { ?> 138 <th scope="row"><label for="domain"><?php _e( 'Domain' ) ?></label></th> 139 <td><?php echo $parsed['scheme'] . '://'; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" /></td> 140 <?php } ?> 171 <th scope="row"><?php _e( 'Site URL' ); ?></th> 172 <td><input name="blog[url]" type="text" id="url" value="<?php echo $parsed_scheme . '://' . esc_attr( $details->domain ) . esc_attr( $details->path ); ?>" /></td> 173 </tr> 174 <?php 175 // In a subdirectory configuration, only the path can be changed. 176 // Scheme and domain are inherited from the network. 177 else : ?> 178 <tr class="form-field"> 179 <th scope="row"><?php _e( 'Domain' ); ?></th> 180 <td><?php echo $parsed_scheme . ':// ' . esc_attr( $details->domain ); ?></td> 141 181 </tr> 142 182 <tr class="form-field form-required"> 143 <?php if ( $is_main_site ) { ?>144 <th scope="row"><?php _e( 'Path' ) ?></th>145 <td><code><?php echo esc_attr( $details->path ) ?></code></td>146 <?php147 } else {148 switch_to_blog( $id );149 ?>150 183 <th scope="row"><label for="path"><?php _e( 'Path' ) ?></label></th> 151 184 <td> 152 185 <input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" /><br /> 186 </td> 187 </tr> 188 <?php endif; ?> 189 190 <?php if ( ! $is_main_site ) : ?> 191 <tr class="form-field"> 192 <th scope="row"></th> 193 <td> 153 194 <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> 154 195 </td> 155 <?php 156 restore_current_blog(); 157 } ?> 158 </tr> 196 </tr> 197 <?php endif; ?> 198 159 199 <tr class="form-field"> 160 200 <th scope="row"><label for="blog_registered"><?php _ex( 'Registered', 'site' ) ?></label></th> … … 192 232 </div> 193 233 <?php 234 restore_current_blog(); 194 235 require( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset
for help on using the changeset viewer.