[ Index ]

PHP Cross Reference of WordPress 3.0 beta 1

[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/wp-admin/ -> ms-sites.php (source)

   1  <?php
   2  require_once ( './admin.php' );
   3  
   4  if ( !is_multisite() )
   5      wp_die( __( 'Multisite support is not enabled.' ) );
   6  
   7  if ( ! current_user_can( 'manage_sites' ) )
   8      wp_die( __( 'You do not have permission to access this page.' ) );
   9  
  10  $title = __( 'Sites' );
  11  $parent_file = 'ms-admin.php';
  12  
  13  wp_enqueue_script( 'admin-forms' );
  14  
  15  require_once ( './admin-header.php' );
  16  
  17  $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
  18  
  19  if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
  20      ?>
  21      <div id="message" class="updated fade"><p>
  22          <?php
  23          switch ( $_GET['action'] ) {
  24              case 'all_notspam':
  25                  _e( 'Sites removed from spam.' );
  26              break;
  27              case 'all_spam':
  28                  _e( 'Sites marked as spam.' );
  29              break;
  30              case 'all_delete':
  31                  _e( 'Sites deleted.' );
  32              break;
  33              case 'delete':
  34                  _e( 'Site deleted.' );
  35              break;
  36              case 'add-blog':
  37                  _e( 'Site added.' );
  38              break;
  39              case 'archive':
  40                  _e( 'Site archived.' );
  41              break;
  42              case 'unarchive':
  43                  _e( 'Site unarchived.' );
  44              break;
  45              case 'activate':
  46                  _e( 'Site activated.' );
  47              break;
  48              case 'deactivate':
  49                  _e( 'Site deactivated.' );
  50              break;
  51              case 'unspam':
  52                  _e( 'Site removed from spam.' );
  53              break;
  54              case 'spam':
  55                  _e( 'Site marked as spam.' );
  56              break;
  57              case 'unmature':
  58                  _e( 'Site marked as not mature.' );
  59              break;
  60              case 'mature':
  61                  _e( 'Site marked as mature.' );
  62              break;
  63              default:
  64                  _e( 'Settings saved.' );
  65              break;
  66          }
  67          ?>
  68      </p></div>
  69      <?php
  70  }
  71  
  72  $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
  73  
  74  switch ( $action ) {
  75      // Edit site
  76      case 'editblog':
  77          $blog_prefix = $wpdb->get_blog_prefix( $id );
  78          $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
  79          $details = get_blog_details( $id );
  80          $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
  81          $is_main_site = is_main_site( $id );
  82          ?>
  83          <div class="wrap">
  84          <?php screen_icon(); ?>
  85          <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>
  86          <form method="post" action="ms-edit.php?action=updateblog">
  87              <?php wp_nonce_field( 'editblog' ); ?>
  88              <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
  89              <div class="metabox-holder" style="width:49%;float:left;">
  90                  <div id="blogedit_bloginfo" class="postbox">
  91                  <h3 class="hndle"><span><?php _e( 'Site info (wp_blogs)' ); ?></span></h3>
  92                  <div class="inside">
  93                      <table class="form-table">
  94                          <tr class="form-field form-required">
  95                              <th scope="row"><?php _e( 'Domain' ) ?></th>
  96                              <?php
  97                              $protocol = is_ssl() ? 'https://' : 'http://';
  98                              if ( $is_main_site ) { ?>
  99                              <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td>
 100                              <?php } else { ?>
 101                              <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td>
 102                              <?php } ?>
 103                          </tr>
 104                          <tr class="form-field form-required">
 105                              <th scope="row"><?php _e( 'Path' ) ?></th>
 106                              <?php if ( $is_main_site ) { ?>
 107                              <td><code><?php echo esc_attr( $details->path ) ?></code></td>
 108                              <?php } else { ?>
 109                              <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' />
 110                              <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>
 111                              <?php } ?>
 112                          </tr>
 113                          <tr class="form-field">
 114                              <th scope="row"><?php _e( 'Registered') ?></th>
 115                              <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td>
 116                          </tr>
 117                          <tr class="form-field">
 118                              <th scope="row"><?php _e('Last Updated') ?></th>
 119                              <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td>
 120                          </tr>
 121                          <tr class="form-field">
 122                              <th scope="row"><?php _e('Public') ?></th>
 123                              <td>
 124                                  <label><input type="radio" style="width:20px;" name="blog[public]" value="1" <?php checked( $details->public, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
 125                                  <label><input type="radio" style="width:20px;" name="blog[public]" value="0" <?php checked( $details->public, 0 ); ?> /> <?php _e( 'No' ) ?></label>
 126                              </td>
 127                          </tr>
 128                          <?php if ( ! $is_main_site ) { ?>
 129                          <tr class="form-field">
 130                              <th scope="row"><?php _e( 'Archived' ); ?></th>
 131                              <td>
 132                                  <label><input type="radio" style="width:20px;" name="blog[archived]" value="1" <?php checked( $details->archived, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
 133                                  <label><input type="radio" style="width:20px;" name="blog[archived]" value="0" <?php checked( $details->archived, 0 ); ?> /> <?php _e( 'No' ) ?></label>
 134                              </td>
 135                          </tr>
 136                          <tr class="form-field">
 137                              <th scope="row"><?php _e( 'Spam' ); ?></th>
 138                              <td>
 139                                  <label><input type="radio" style="width:20px;" name="blog[spam]" value="1" <?php checked( $details->spam, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
 140                                  <label><input type="radio" style="width:20px;" name="blog[spam]" value="0" <?php checked( $details->spam, 0 ); ?> /> <?php _e( 'No' ) ?></label>
 141                              </td>
 142                          </tr>
 143                          <tr class="form-field">
 144                              <th scope="row"><?php _e( 'Deleted' ); ?></th>
 145                              <td>
 146                                  <label><input type="radio" style="width:20px;" name="blog[deleted]" value="1" <?php checked( $details->deleted, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
 147                                  <label><input type="radio" style="width:20px;" name="blog[deleted]" value="0" <?php checked( $details->deleted, 0 ); ?> /> <?php _e( 'No' ) ?></label>
 148                              </td>
 149                          </tr>
 150                          <tr class="form-field">
 151                              <th scope="row"><?php _e( 'Mature' ); ?></th>
 152                              <td>
 153                                  <label><input type="radio" style="width:20px;" name="blog[mature]" value="1" <?php checked( $details->mature, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
 154                                  <label><input type="radio" style="width:20px;" name="blog[mature]" value="0" <?php checked( $details->mature, 0); ?> /> <?php _e( 'No' ) ?></label>
 155                              </td>
 156                          </tr>
 157                          <?php } ?>
 158                      </table>
 159                      <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
 160                  </div>
 161                  </div>
 162  
 163                  <div id="blogedit_blogoptions" class="postbox" >
 164                  <h3 class="hndle"><span><?php printf( __( 'Site options (%soptions)' ), $blog_prefix ); ?></span></h3>
 165                  <div class="inside">
 166                      <table class="form-table">
 167                          <?php
 168                          $editblog_default_role = 'subscriber';
 169                          foreach ( $options as $option ) {
 170                              if ( $option->option_name == 'default_role' )
 171                                  $editblog_default_role = $option->option_value;
 172                              $disabled = false;
 173                              $class = 'all-options';
 174                              if ( is_serialized( $option->option_value ) ) {
 175                                  if ( is_serialized_string( $option->option_value ) ) {
 176                                      $option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' );
 177                                  } else {
 178                                      $option->option_value = 'SERIALIZED DATA';
 179                                      $disabled = true;
 180                                      $class = 'all-options disabled';
 181                                  }
 182                              }
 183                              if ( strpos( $option->option_value, "\n" ) !== false ) {
 184                              ?>
 185                                  <tr class="form-field">
 186                                      <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
 187                                      <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 wp_htmledit_pre( $option->option_value ) ?></textarea></td>
 188                                  </tr>
 189                              <?php
 190                              } else {
 191                              ?>
 192                                  <tr class="form-field">
 193                                      <th scope="row"><?php esc_html_e( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th>
 194                                      <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
 195                                      <td><code><?php esc_html_e( $option->option_value ) ?></code></td>
 196                                      <?php } else { ?>
 197                                      <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>
 198                                      <?php } ?>
 199                                  </tr>
 200                              <?php
 201                              }
 202                          } // End foreach
 203                          ?>
 204                      </table>
 205                      <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
 206                  </div>
 207                  </div>
 208              </div>
 209  
 210              <div class="metabox-holder" style="width:49%;float:right;">
 211                  <?php
 212                  // Site Themes
 213                  $themes = get_themes();
 214                  $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id );
 215                  $allowed_themes = get_site_option( 'allowedthemes' );
 216  
 217                  if ( ! $allowed_themes )
 218                      $allowed_themes = array_keys( $themes );
 219  
 220                  $out = '';
 221                  foreach ( $themes as $key => $theme ) {
 222                      $theme_key = esc_html( $theme['Stylesheet'] );
 223                      if ( ! isset( $allowed_themes[$theme_key] ) ) {
 224                          $checked = isset( $blog_allowed_themes[ $theme_key ] ) ? 'checked="checked"' : '';
 225                          $out .= '<tr class="form-field form-required">
 226                                  <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html( $key ) . '</th>
 227                                  <td><label><input name="theme[' . esc_attr( $theme_key ) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/> ' . __( 'Active' ) . '</label></td>
 228                              </tr>';
 229                      }
 230                  }
 231  
 232                  if ( $out != '' ) {
 233                  ?>
 234                  <div id="blogedit_blogthemes" class="postbox">
 235                  <h3 class="hndle"><span><?php esc_html_e( 'Site Themes' ); ?></span></h3>
 236                  <div class="inside">
 237                      <p class="description"><?php _e( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?></p>
 238                      <table class="form-table">
 239                          <?php echo $out; ?>
 240                      </table>
 241                      <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
 242                  </div></div>
 243                  <?php }
 244  
 245                  // Site users
 246                  $blogusers = get_users_of_blog( $id );
 247                  if ( is_array( $blogusers ) ) {
 248                      echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
 249                      echo '<table class="form-table">';
 250                      echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
 251                      reset( $blogusers );
 252                      foreach ( (array) $blogusers as $key => $val ) {
 253                          if ( isset( $val->meta_value ) && ! $val->meta_value )
 254                              continue;
 255                          $t = @unserialize( $val->meta_value );
 256                          if ( is_array( $t ) ) {
 257                              reset( $t );
 258                              $existing_role = key( $t );
 259                          }
 260                          echo '<tr><td><a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a></td>';
 261                          if ( $val->user_id != $current_user->data->ID ) {
 262                              ?>
 263                              <td>
 264                                  <select name="role[<?php echo $val->user_id ?>]" id="new_role"><?php
 265                                      foreach ( $editblog_roles as $role => $role_assoc ){
 266                                          $name = translate_user_role( $role_assoc['name'] );
 267                                          echo '<option ' . selected( $role, $existing_role ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
 268                                      }
 269                                      ?>
 270                                  </select>
 271                              </td>
 272                              <td>
 273                                  <input type="text" name="user_password[<?php echo esc_attr( $val->user_id ) ?>]" />
 274                              </td>
 275                              <?php
 276                              echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $val->user_id ) . ']" /></td>';
 277                          } else {
 278                              echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>";
 279                          }
 280                          echo '</tr>';
 281                      }
 282                      echo "</table>";
 283                      echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>';
 284                      echo "</div></div>";
 285                  }
 286                  ?>
 287  
 288                  <div id="blogedit_blogadduser" class="postbox">
 289                  <h3 class="hndle"><span><?php _e( 'Add a new user' ); ?></span></h3>
 290                  <div class="inside">
 291                      <p class="description"><?php _e( 'Enter the username of an existing user and hit "Update Options" to add the user.' ) ?></p>
 292                      <table class="form-table">
 293                              <tr>
 294                                  <th scope="row"><?php _e( 'User&nbsp;Login:' ) ?></th>
 295                                  <td><input type="text" name="newuser" id="newuser" /></td>
 296                              </tr>
 297                              <tr>
 298                                  <th scope="row"><?php _e( 'Role:' ) ?></th>
 299                                  <td>
 300                                      <select name="new_role" id="new_role">
 301                                      <?php
 302                                      reset( $editblog_roles );
 303                                      foreach ( $editblog_roles as $role => $role_assoc ){
 304                                          $name = translate_user_role( $role_assoc['name'] );
 305                                          $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '';
 306                                          echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
 307                                      }
 308                                      ?>
 309                                      </select>
 310                                  </td>
 311                              </tr>
 312                          </table>
 313                      <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
 314                  </div>
 315                  </div>
 316  
 317                  <div id="blogedit_miscoptions" class="postbox">
 318                  <h3 class="hndle"><span><?php _e( 'Misc Site Actions' ) ?></span></h3>
 319                  <div class="inside">
 320                      <table class="form-table">
 321                              <?php do_action( 'wpmueditblogaction', $id ); ?>
 322                      </table>
 323                      <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
 324                  </div>
 325                  </div>
 326              </div>
 327  
 328              <div style="clear:both;"></div>
 329          </form>
 330          </div>
 331          <?php
 332      break;
 333  
 334      // List sites
 335      case 'list':
 336      default:
 337          $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
 338          if ( empty($pagenum) )
 339              $pagenum = 1;
 340  
 341          $per_page = (int) get_user_option( 'ms_sites_per_page' );
 342          if ( empty( $per_page ) || $per_page < 1 )
 343              $per_page = 15;
 344  
 345          $per_page = apply_filters( 'ms_sites_per_page', $per_page );
 346  
 347          $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
 348          $like_s = esc_sql( like_escape( $s ) );
 349  
 350          $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
 351  
 352          if ( isset( $_GET['searchaction'] ) ) {
 353              if ( 'name' == $_GET['searchaction'] ) {
 354                  $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) ";
 355              } elseif ( 'id' == $_GET['searchaction'] ) {
 356                  $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' ";
 357              } elseif ( 'ip' == $_GET['searchaction'] ) {
 358                  $query = "SELECT *
 359                      FROM {$wpdb->blogs}, {$wpdb->registration_log}
 360                      WHERE site_id = '{$wpdb->siteid}'
 361                      AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
 362                      AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')";
 363              }
 364          }
 365  
 366          $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
 367          if ( $order_by == 'registered' ) {
 368              $query .= ' ORDER BY registered ';
 369          } elseif ( $order_by == 'lastupdated' ) {
 370              $query .= ' ORDER BY last_updated ';
 371          } elseif ( $order_by == 'blogname' ) {
 372              $query .= ' ORDER BY domain ';
 373          } else {
 374              $order_by = 'id';
 375              $query .= " ORDER BY {$wpdb->blogs}.blog_id ";
 376          }
 377  
 378          $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? "DESC" : "ASC";
 379          $query .= $order;
 380  
 381          $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(blog_id)', $query ) );
 382  
 383          $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
 384          $blog_list = $wpdb->get_results( $query, ARRAY_A );
 385  
 386          $num_pages = ceil($total / $per_page);
 387          $page_links = paginate_links( array(
 388              'base' => add_query_arg( 'paged', '%#%' ),
 389              'format' => '',
 390              'prev_text' => __( '&laquo;' ),
 391              'next_text' => __( '&raquo;' ),
 392              'total' => $num_pages,
 393              'current' => $pagenum
 394          ));
 395  
 396          if ( empty( $_GET['mode'] ) )
 397              $mode = 'list';
 398          else
 399              $mode = esc_attr( $_GET['mode'] );
 400          ?>
 401  
 402          <div class="wrap">
 403          <?php screen_icon(); ?>
 404          <h2><?php _e('Sites') ?>
 405          <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>
 406          <?php
 407          if ( isset( $_GET['s'] ) && $_GET['s'] )
 408          printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
 409          ?>
 410          </h2>
 411  
 412          <form action="ms-sites.php" method="get" id="ms-search">
 413          <p class="search-box">
 414          <input type="hidden" name="action" value="blogs" />
 415          <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" />
 416          <input type="submit" class="button" value="<?php esc_attr_e( 'Search Site by' ) ?>" />
 417          <select name="searchaction">
 418              <option value="name" selected="selected"><?php _e( 'Name' ); ?></option>
 419              <option value="id"><?php _e( 'ID' ); ?></option>
 420              <option value="ip"><?php _e( 'IP address' ); ?></option>
 421          </select>
 422          </p>
 423          </form>
 424  
 425          <form id="form-site-list" action="ms-edit.php?action=allblogs" method="post">
 426          <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" />
 427          <div class="tablenav">
 428          <div class="alignleft actions">
 429              <select name="action">
 430                  <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
 431                  <option value="delete"><?php _e( 'Delete' ); ?></option>
 432                  <option value="spam"><?php _e( 'Mark as Spam' ); ?></option>
 433                  <option value="notspam"><?php _e( 'Not Spam' ); ?></option>
 434              </select>
 435              <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
 436              <?php wp_nonce_field( 'bulk-ms-sites' ); ?>
 437          </div>
 438  
 439          <?php if ( $page_links ) { ?>
 440          <div class="tablenav-pages">
 441          <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
 442          number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
 443          number_format_i18n( min( $pagenum * $per_page, $num_pages ) ),
 444          number_format_i18n( $num_pages ),
 445          $page_links
 446          ); echo $page_links_text; ?>
 447          </div>
 448          <?php } ?>
 449  
 450          <div class="view-switch">
 451              <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
 452              <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
 453          </div>
 454  
 455          </div>
 456  
 457          <div class="clear"></div>
 458  
 459          <?php
 460          // define the columns to display, the syntax is 'internal name' => 'display name'
 461          $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
 462          $sites_columns = array(
 463              'id'           => __( 'ID' ),
 464              'blogname'     => $blogname_columns,
 465              'lastupdated'  => __( 'Last Updated'),
 466              'registered'   => __( 'Registered' ),
 467              'users'        => __( 'Users' )
 468          );
 469  
 470          if ( has_filter( 'wpmublogsaction' ) )
 471              $sites_columns['plugins'] = __( 'Actions' );
 472  
 473          $sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
 474          ?>
 475  
 476          <table class="widefat">
 477              <thead>
 478                  <tr>
 479                  <th class="manage-column column-cb check-column" id="cb" scope="col">
 480                      <input type="checkbox" />
 481                  </th>
 482                  <?php
 483                  $col_url = '';
 484                  foreach($sites_columns as $column_id => $column_display_name) {
 485                      $column_link = "<a href='";
 486                      $order2 = '';
 487                      if ( $order_by == $column_id )
 488                          $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC';
 489  
 490                      $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) );
 491                      $column_link .= "'>{$column_display_name}</a>";
 492                      $col_url .= '<th scope="col">' . ( ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ) . '</th>';
 493                  }
 494                  echo $col_url ?>
 495                  </tr>
 496              </thead>
 497              <tfoot>
 498                  <tr>
 499                  <th class="manage-column column-cb check-column" id="cb1" scope="col">
 500                      <input type="checkbox" />
 501                  </th>
 502                      <?php echo $col_url ?>
 503                  </tr>
 504              </tfoot>
 505              <tbody id="the-site-list" class="list:site">
 506              <?php
 507              $status_list = array( 'archived' => array( 'site-archived', __( 'Archived' ) ), 'spam' => array( 'site-spammed', __( 'Spam' ) ), 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), 'mature' => array( 'site-mature', __( 'Mature' ) ) );
 508              if ( $blog_list ) {
 509                  $class = '';
 510                  foreach ( $blog_list as $blog ) {
 511                      $class = ( 'alternate' == $class ) ? '' : 'alternate';
 512                      reset( $status_list );
 513  
 514                      $blog_states = array();
 515                      foreach ( $status_list as $status => $col ) {
 516                          if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
 517                              $class = $col[0];
 518                              $blog_states[] = $col[1];
 519                          }
 520                      }
 521                      $blog_state = '';
 522                      if ( ! empty( $blog_states ) ) {
 523                          $state_count = count( $blog_states );
 524                          $i = 0;
 525                          $blog_state .= ' - ';
 526                          foreach ( $blog_states as $state ) {
 527                              ++$i;
 528                              ( $i == $state_count ) ? $sep = '' : $sep = ', ';
 529                              $blog_state .= "<span class='post-state'>$state$sep</span>";
 530                          }
 531                      }
 532                      echo "<tr class='$class'>";
 533  
 534                      $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
 535                      foreach ( $sites_columns as $column_name=>$column_display_name ) {
 536                          switch ( $column_name ) {
 537                              case 'id': ?>
 538                                  <th scope="row" class="check-column">
 539                                      <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
 540                                  </th>
 541                                  <th valign="top" scope="row">
 542                                      <?php echo $blog['blog_id'] ?>
 543                                  </th>
 544                              <?php
 545                              break;
 546  
 547                              case 'blogname': ?>
 548                                  <td class="column-title">
 549                                      <a href="<?php echo esc_url( admin_url( 'ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
 550                                      <?php
 551                                      if ( 'list' != $mode )
 552                                          echo '<p>' . sprintf( _x( '%1$s &#8211; <em>%2$s', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</em></p>';
 553  
 554                                      // Preordered.
 555                                      $actions = array(
 556                                          'edit' => '', 'backend' => '',
 557                                          'activate' => '', 'deactivate' => '',
 558                                          'archive' => '', 'unarchive' => '',
 559                                          'spam' => '', 'unspam' => '',
 560                                          'delete' => '',
 561                                          'visit' => '',
 562                                      );
 563  
 564                                      $actions['edit']    = '<span class="edit"><a href="' . esc_url( admin_url( 'ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a><span>';
 565                                      $actions['backend']    = "<span class='backend'><a href='" . esc_url( get_admin_url($blog['blog_id']) ) . "' class='edit'>" . __( 'Backend' ) . '</a></span>';
 566                                      if ( $current_site->blog_id != $blog['blog_id'] ) {
 567                                          if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
 568                                              $actions['activate']    = '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to activate the site %s" ), $blogname ) ) ) ) . '">' . __( 'Activate' ) . '</a></span>';
 569                                          else
 570                                              $actions['deactivate']    = '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to deactivate the site %s" ), $blogname ) ) ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
 571  
 572                                          if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
 573                                              $actions['unarchive']    = '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unarchive the site %s." ), $blogname ) ) ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
 574                                          else
 575                                              $actions['archive']    = '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to archive the site %s." ), $blogname ) ) ) ) . '">' . __( 'Archive' ) . '</a></span>';
 576  
 577                                          if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
 578                                              $actions['unspam']    = '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unspam the site %s." ), $blogname ) ) ) ) . '">' . __( 'Not Spam' ) . '</a></span>';
 579                                          else
 580                                              $actions['spam']    = '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as spam." ), $blogname ) ) ) ) . '">' . __( 'Spam' ) . '</a></span>';
 581  
 582                                          $actions['delete']    = '<span class="delete"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to delete the site %s." ), $blogname ) ) ) ) . '">' . __( 'Delete' ) . '</a></span>';
 583                                      }
 584  
 585                                      $actions['visit']    = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a>';
 586                                      $actions = array_filter( $actions );
 587                                      if ( count( $actions ) ) : ?>
 588                                      <div class="row-actions">
 589                                          <?php echo implode( ' | ', $actions ); ?>
 590                                      </div>
 591                                      <?php endif; ?>
 592                                  </td>
 593                              <?php
 594                              break;
 595  
 596                              case 'lastupdated': ?>
 597                                  <td valign="top">
 598                                      <?php
 599                                      if ( 'list' == $mode )
 600                                          $date = 'Y/m/d';
 601                                      else
 602                                          $date = 'Y/m/d \<\b\r \/\> g:i:s a';
 603                                      echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( __( $date ), $blog['last_updated'] ); ?>
 604                                  </td>
 605                              <?php
 606                              break;
 607                          case 'registered': ?>
 608                                  <td valign="top">
 609                                  <?php
 610                                  if ( $blog['registered'] == '0000-00-00 00:00:00' )
 611                                      echo '&#x2014;';
 612                                  else
 613                                      echo mysql2date( __( $date ), $blog['registered'] );
 614                                  ?>
 615                                  </td>
 616                          <?php
 617                          break;
 618                              case 'users': ?>
 619                                  <td valign="top">
 620                                      <?php
 621                                      $blogusers = get_users_of_blog( $blog['blog_id'] );
 622                                      if ( is_array( $blogusers ) ) {
 623                                          $blogusers_warning = '';
 624                                          if ( count( $blogusers ) > 5 ) {
 625                                              $blogusers = array_slice( $blogusers, 0, 5 );
 626                                              $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>';
 627                                          }
 628                                          foreach ( $blogusers as $key => $val ) {
 629                                              echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $val->user_id ) ) . '">' . esc_html( $val->user_login ) . '</a> ';
 630                                              if ( 'list' != $mode )
 631                                                  echo '(' . $val->user_email . ')';
 632                                              echo '<br />';
 633                                          }
 634                                          if ( $blogusers_warning != '' )
 635                                              echo '<strong>' . $blogusers_warning . '</strong><br />';
 636                                      }
 637                                      ?>
 638                                  </td>
 639                              <?php
 640                              break;
 641  
 642                              case 'plugins': ?>
 643                                  <?php if ( has_filter( 'wpmublogsaction' ) ) { ?>
 644                                  <td valign="top">
 645                                      <?php do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
 646                                  </td>
 647                                  <?php } ?>
 648                              <?php break;
 649  
 650                              default: ?>
 651                                  <?php if ( has_filter( 'manage_blogs_custom_column' ) ) { ?>
 652                                  <td valign="top">
 653                                      <?php do_action( 'manage_blogs_custom_column', $column_name, $blog['blog_id'] ); ?>
 654                                  </td>
 655                                  <?php } ?>
 656                              <?php break;
 657                          }
 658                      }
 659                      ?>
 660                      </tr>
 661                      <?php
 662                  }
 663              } else { ?>
 664                  <tr>
 665                      <td colspan="<?php echo (int) count( $sites_columns ); ?>"><?php _e( 'No blogs found.' ) ?></td>
 666                  </tr>
 667              <?php
 668              } // end if ($blogs)
 669              ?>
 670  
 671              </tbody>
 672          </table>
 673          <div class="tablenav">
 674              <?php
 675              if ( $page_links )
 676                  echo "<div class='tablenav-pages'>$page_links_text</div>";
 677              ?>
 678  
 679              <div class="alignleft actions">
 680              <select name="action2">
 681                  <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
 682                  <option value="delete"><?php _e( 'Delete' ); ?></option>
 683                  <option value="spam"><?php _e( 'Mark as Spam' ); ?></option>
 684                  <option value="notspam"><?php _e( 'Not Spam' ); ?></option>
 685              </select>
 686              <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
 687              </div>
 688              <br class="clear" />
 689          </div>
 690  
 691          </form>
 692          </div>
 693  
 694          <div class="wrap">
 695              <a name="form-add-site"></a>
 696              <h2><?php _e( 'Add Site' ) ?></h2>
 697              <form method="post" action="ms-edit.php?action=addblog">
 698                  <?php wp_nonce_field( 'add-blog' ) ?>
 699                  <table class="form-table">
 700                      <tr class="form-field form-required">
 701                          <th scope="row"><?php _e( 'Site Address' ) ?></th>
 702                          <td>
 703                          <?php if ( is_subdomain_install() ) { ?>
 704                              <input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo $current_site->domain;?>
 705                          <?php } else {
 706                              echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>
 707                          <?php }
 708                          echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>';
 709                          ?>
 710                          </td>
 711                      </tr>
 712                      <tr class="form-field form-required">
 713                          <th scope="row"><?php _e( 'Site Title' ) ?></th>
 714                          <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td>
 715                      </tr>
 716                      <tr class="form-field form-required">
 717                          <th scope="row"><?php _e( 'Admin Email' ) ?></th>
 718                          <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td>
 719                      </tr>
 720                      <tr class="form-field">
 721                          <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>
 722                      </tr>
 723                  </table>
 724                  <p class="submit">
 725                      <input class="button" type="submit" name="go" value="<?php esc_attr_e( 'Add Site' ) ?>" /></p>
 726              </form>
 727          </div>
 728          <?php
 729      break;
 730  } // end switch( $action )
 731  
 732  include ( './admin-footer.php' ); ?>


Generated: Mon Apr 5 14:26:09 2010 Cross-referenced by PHPXref 0.7