Make WordPress Core

Changeset 32759

Timestamp:
06/14/2015 07:08:30 AM (9 years ago)
Author:
jeremyfelt
Message:

Capture domain and path when editing sites on a subdomain network

When a network is configured as subdomain, allow for the input of arbitrary domain and path combinations when editing a site rather than just the domain.

This takes a step or two toward #32503.

Props @scribu, @ericlewis, @jeremyfelt.
See #22383.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/site-info.php

    r32758 r32759  
    4747}
    4848
    49 $parsed = parse_url( $details->siteurl );
     49$parsed );
    5050$is_main_site = is_main_site( $id );
    5151
     
    5858    delete_option( 'rewrite_rules' );
    5959
    60     // Update blogs table.
    6160    $blog_data = wp_unslash( $_POST['blog'] );
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
    6285    $existing_details = get_blog_details( $id, false );
    6386    $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
     
    6992        }
    7093    }
     94
    7195    update_blog_details( $id, $blog_data );
    7296
    7397    if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
    7498        $new_details = get_blog_details( $id, false );
    75         $blog_address = esc_url_raw( $new_details->domain . $new_details->path );
     99        $blog_address = );
    76100        if ( get_option( 'siteurl' ) != $blog_address ) {
    77101            update_option( 'siteurl', $blog_address );
     
    126150        echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
    127151    }
    128 } ?>
     152}
     153
     154switch_to_blog( $id );
     155?>
    129156<form method="post" action="site-info.php?action=update-site">
    130157    <?php wp_nonce_field( 'edit-site' ); ?>
    131158    <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
    132159    <table class="form-table">
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
    133170        <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>
    141181        </tr>
    142182        <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             <?php
    147             } else {
    148                 switch_to_blog( $id );
    149             ?>
    150183            <th scope="row"><label for="path"><?php _e( 'Path' ) ?></label></th>
    151184            <td>
    152185                <input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" /><br />
     186
     187
     188
     189
     190
     191
     192
     193
    153194                <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>
    154195            </td>
    155             <?php
    156                 restore_current_blog();
    157             } ?>
    158         </tr>
     196        </tr>
     197        <?php endif; ?>
     198
    159199        <tr class="form-field">
    160200            <th scope="row"><label for="blog_registered"><?php _ex( 'Registered', 'site' ) ?></label></th>
     
    192232</div>
    193233<?php
     234
    194235require( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset for help on using the changeset viewer.