Make WordPress Core


Ignore:
Timestamp:
10/21/2010 06:35:52 PM (15 years ago)
Author:
ryan
Message:

Tabbed interface for site editing. see #15174

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/sites.php

    r15886 r15903  
    2121add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
    2222
    23 if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) {
    24     add_contextual_help($current_screen,
    25         '<p>' . __('This extensive list of options has five modules: Site Info, Site Options, allowing Site Themes for this given site, changing user roles and passwords for that site, adding a new user, and Miscellaneous Site Actions (upload size limits).') . '</p>' .
    26         '<p>' . __('Note that some fields in Site Options are grayed out and say Serialized Data. These are stored values in the database which you cannot change from here.') . '</p>' .
    27         '<p><strong>' . __('For more information:') . '</strong></p>' .
    28         '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_Edit_Site" target="_blank">Documentation on Editing Sites</a>') . '</p>' .
    29         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    30     );
    31 } else {
    32     add_contextual_help($current_screen,
    33         '<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' .
    34         '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' .
    35         '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' .
    36         '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' .
    37         '<li>' . __('Dashboard to the Dashboard for that site.') . '</li>' .
    38         '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' .
    39         '<li>' . __('Delete which is a permanent action after the confirmations screen.') . '</li>' .
    40         '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' .
    41         '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' .
    42         '<p>' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '</p>' .
    43         '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' .
    44         '<p><strong>' . __('For more information:') . '</strong></p>' .
    45         '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_SubPanel" target="_blank">Documentation on Sites</a>') . '</p>' .
    46         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    47     );
    48 }
     23add_contextual_help($current_screen,
     24    '<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' .
     25    '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' .
     26    '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' .
     27    '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' .
     28    '<li>' . __('Dashboard to the Dashboard for that site.') . '</li>' .
     29    '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' .
     30    '<li>' . __('Delete which is a permanent action after the confirmations screen.') . '</li>' .
     31    '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' .
     32    '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' .
     33    '<p>' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '</p>' .
     34    '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' .
     35    '<p><strong>' . __('For more information:') . '</strong></p>' .
     36    '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_SubPanel" target="_blank">Documentation on Sites</a>') . '</p>' .
     37    '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
     38);
    4939
    5040$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
     
    9686    // Edit site
    9787    case 'editblog':
    98         $blog_prefix = $wpdb->get_blog_prefix( $id );
    99         $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
    100         $details = get_blog_details( $id );
    101         if ( $details->site_id != $wpdb->siteid )
    102             wp_die( __( 'You do not have permission to access this page.' ) );
    103 
    104         $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
    105         $is_main_site = is_main_site( $id );
    106 
    107         require_once( '../admin-header.php' );
    108         ?>
    109         <div class="wrap">
    110         <?php screen_icon('index'); ?>
    111         <h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2>
    112         <?php echo $msg; ?>
    113         <form method="post" action="edit.php?action=updateblog">
    114             <?php wp_nonce_field( 'editblog' ); ?>
    115             <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
    116             <div class="metabox-holder" style="width:49%;float:left;">
    117                 <div id="blogedit_bloginfo" class="postbox">
    118                 <h3 class="hndle"><span><?php _e( 'Site info (wp_blogs)' ); ?></span></h3>
    119                 <div class="inside">
    120                     <table class="form-table">
    121                         <tr class="form-field form-required">
    122                             <th scope="row"><?php _e( 'Domain' ) ?></th>
    123                             <?php
    124                             $protocol = is_ssl() ? 'https://' : 'http://';
    125                             if ( $is_main_site ) { ?>
    126                             <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td>
    127                             <?php } else { ?>
    128                             <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td>
    129                             <?php } ?>
    130                         </tr>
    131                         <tr class="form-field form-required">
    132                             <th scope="row"><?php _e( 'Path' ) ?></th>
    133                             <?php if ( $is_main_site ) { ?>
    134                             <td><code><?php echo esc_attr( $details->path ) ?></code></td>
    135                             <?php } else { ?>
    136                             <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' />
    137                             <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td>
    138                             <?php } ?>
    139                         </tr>
    140                         <tr class="form-field">
    141                             <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th>
    142                             <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td>
    143                         </tr>
    144                         <tr class="form-field">
    145                             <th scope="row"><?php _e('Last Updated') ?></th>
    146                             <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td>
    147                         </tr>
    148                         <?php
    149                         $radio_fields = array( 'public' => __( 'Public' ) );
    150                         if ( ! $is_main_site ) {
    151                             $radio_fields['archived'] = __( 'Archived' );
    152                             $radio_fields['spam']     = _x( 'Spam', 'site' );
    153                             $radio_fields['deleted']  = __( 'Deleted' );
    154                         }
    155                         $radio_fields['mature'] = __( 'Mature' );
    156                         foreach ( $radio_fields as $field_key => $field_label ) {
    157                         ?>
    158                         <tr>
    159                             <th scope="row"><?php echo $field_label; ?></th>
    160                             <td>
    161                                 <input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_1" value="1"<?php checked( $details->$field_key, 1 ); ?> />
    162                                 <label for="blog_<?php echo $field_key; ?>_1"><?php _e('Yes'); ?></label>
    163                                 <input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_0" value="0"<?php checked( $details->$field_key, 0 ); ?> />
    164                                 <label for="blog_<?php echo $field_key; ?>_0"><?php _e('No'); ?></label>
    165                             </td>
    166                         </tr>
    167                         <?php } ?>
    168                     </table>
    169                     <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
    170                 </div>
    171                 </div>
    172 
    173                 <div id="blogedit_blogoptions" class="postbox" >
    174                 <h3 class="hndle"><span><?php printf( __( 'Site options (%soptions)' ), $blog_prefix ); ?></span></h3>
    175                 <div class="inside">
    176                     <table class="form-table">
    177                         <?php
    178                         $editblog_default_role = 'subscriber';
    179                         foreach ( $options as $option ) {
    180                             if ( $option->option_name == 'default_role' )
    181                                 $editblog_default_role = $option->option_value;
    182                             $disabled = false;
    183                             $class = 'all-options';
    184                             if ( is_serialized( $option->option_value ) ) {
    185                                 if ( is_serialized_string( $option->option_value ) ) {
    186                                     $option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' );
    187                                 } else {
    188                                     $option->option_value = 'SERIALIZED DATA';
    189                                     $disabled = true;
    190                                     $class = 'all-options disabled';
    191                                 }
    192                             }
    193                             if ( strpos( $option->option_value, "\n" ) !== false ) {
    194                             ?>
    195                                 <tr class="form-field">
    196                                     <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
    197                                     <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo wp_htmledit_pre( $option->option_value ) ?></textarea></td>
    198                                 </tr>
    199                             <?php
    200                             } else {
    201                             ?>
    202                                 <tr class="form-field">
    203                                     <th scope="row"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th>
    204                                     <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
    205                                     <td><code><?php echo esc_html( $option->option_value ) ?></code></td>
    206                                     <?php } else { ?>
    207                                     <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
    208                                     <?php } ?>
    209                                 </tr>
    210                             <?php
    211                             }
    212                         } // End foreach
    213                         ?>
    214                     </table>
    215                     <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
    216                 </div>
    217                 </div>
    218             </div>
    219 
    220             <div class="metabox-holder" style="width:49%;float:right;">
    221                 <?php
    222                 // Site Themes
    223                 $themes = get_themes();
    224                 $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id );
    225                 $allowed_themes = get_site_option( 'allowedthemes' );
    226 
    227                 if ( ! $allowed_themes )
    228                     $allowed_themes = array_keys( $themes );
    229 
    230                 $out = '';
    231                 foreach ( $themes as $key => $theme ) {
    232                     $theme_key = esc_html( $theme['Stylesheet'] );
    233                     if ( ! isset( $allowed_themes[$theme_key] ) ) {
    234                         $checked = isset( $blog_allowed_themes[ $theme_key ] ) ? 'checked="checked"' : '';
    235                         $out .= '<tr class="form-field form-required">
    236                                 <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html( $key ) . '</th>
    237                                 <td><label><input name="theme[' . esc_attr( $theme_key ) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/> ' . __( 'Active' ) . '</label></td>
    238                             </tr>';
    239                     }
    240                 }
    241 
    242                 if ( $out != '' ) {
    243                 ?>
    244                 <div id="blogedit_blogthemes" class="postbox">
    245                 <h3 class="hndle"><span><?php esc_html_e( 'Site Themes' ); ?></span></h3>
    246                 <div class="inside">
    247                     <p class="description"><?php _e( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?></p>
    248                     <table class="form-table">
    249                         <?php echo $out; ?>
    250                     </table>
    251                     <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
    252                 </div></div>
    253                 <?php }
    254 
    255                 // Site users
    256                 $blogusers = get_users( array( 'blog_id' => $id, 'number' => 20 ) );
    257                 if ( is_array( $blogusers ) ) {
    258                     echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
    259                     echo '<table class="form-table">';
    260                     echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
    261                     $user_count = 0;
    262                     foreach ( $blogusers as $user_id => $user_object ) {
    263                         $user_count++;
    264                         $existing_role = reset( $user_object->roles );
    265 
    266                         echo '<tr><td><a href="user-edit.php?user_id=' . $user_id . '">' . $user_object->user_login . '</a></td>';
    267                         if ( $user_id != $current_user->data->ID ) {
    268                             ?>
    269                             <td>
    270                                 <select name="role[<?php echo $user_id ?>]" id="new_role_1"><?php
    271                                     foreach ( $editblog_roles as $role => $role_assoc ){
    272                                         $name = translate_user_role( $role_assoc['name'] );
    273                                         echo '<option ' . selected( $role, $existing_role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
    274                                     }
    275                                     ?>
    276                                 </select>
    277                             </td>
    278                             <td>
    279                                 <input type="text" name="user_password[<?php echo esc_attr( $user_id ) ?>]" />
    280                             </td>
    281                             <?php
    282                             echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $user_id ) . ']" /></td>';
    283                         } else {
    284                             echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>";
    285                         }
    286                         echo '</tr>';
    287                     }
    288                     echo "</table>";
    289                     echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>';
    290                     if ( 20 == $user_count )
    291                         echo '<p>' . sprintf( __('First 20 users shown. <a href="%s">Manage all users</a>.'), get_admin_url($id, 'users.php') ) . '</p>';
    292                     echo "</div></div>";
    293                 }
    294                 ?>
    295 
    296                 <div id="blogedit_blogadduser" class="postbox">
    297                 <h3 class="hndle"><span><?php _e( 'Add a new user' ); ?></span></h3>
    298                 <div class="inside">
    299                     <p class="description"><?php _e( 'Enter the username of an existing user and hit &#8220;Update Options&#8221; to add the user.' ) ?></p>
    300                     <table class="form-table">
    301                             <tr>
    302                                 <th scope="row"><?php _e( 'User&nbsp;Login:' ) ?></th>
    303                                 <td><input type="text" name="newuser" id="newuser" /></td>
    304                             </tr>
    305                             <tr>
    306                                 <th scope="row"><?php _e( 'Role:' ) ?></th>
    307                                 <td>
    308                                     <select name="new_role" id="new_role_0">
    309                                     <?php
    310                                     reset( $editblog_roles );
    311                                     foreach ( $editblog_roles as $role => $role_assoc ){
    312                                         $name = translate_user_role( $role_assoc['name'] );
    313                                         $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '';
    314                                         echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
    315                                     }
    316                                     ?>
    317                                     </select>
    318                                 </td>
    319                             </tr>
    320                         </table>
    321                     <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
    322                 </div>
    323                 </div>
    324 
    325                 <div id="blogedit_miscoptions" class="postbox">
    326                 <h3 class="hndle"><span><?php _e( 'Misc Site Actions' ) ?></span></h3>
    327                 <div class="inside">
    328                     <table class="form-table">
    329                             <?php do_action( 'wpmueditblogaction', $id ); ?>
    330                     </table>
    331                     <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
    332                 </div>
    333                 </div>
    334             </div>
    335 
    336             <div style="clear:both;"></div>
    337         </form>
    338         </div>
    339         <?php
     88        // No longer used.
    34089    break;
    34190
Note: See TracChangeset for help on using the changeset viewer.