[ Index ]

PHP Cross Reference of WordPress 3.0 beta 1

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

title

Body

[close]

/wp-admin/ -> my-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('read') )
   8      wp_die( __( 'You do not have sufficient permissions to view this page.' ) );
   9  
  10  $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
  11  
  12  $blogs = get_blogs_of_user( $current_user->id );
  13  
  14  if ( empty( $blogs ) )
  15      wp_die( __( 'You must be a member of at least one site to use this page.' ) );
  16  
  17  $updated = false;
  18  if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
  19      check_admin_referer( 'update-my-sites' );
  20  
  21      $blog = get_blog_details( (int) $_POST['primary_blog'] );
  22      if ( $blog && isset( $blog->domain ) ) {
  23          update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
  24          $updated = true;
  25      } else {
  26          wp_die( __( "The primary site, which you have choosen, doesn't exists." ) );    
  27      }
  28  }
  29  
  30  $title = __( 'My Sites' );
  31  $parent_file = 'index.php';
  32  require_once ( './admin-header.php' );
  33  
  34  if ( $updated ) { ?>
  35      <div id="message" class="updated fade"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
  36  <?php } ?>
  37  
  38  <div class="wrap">
  39  <?php screen_icon(); ?>
  40  <h2><?php esc_html_e( $title ); ?></h2>
  41  <form id="myblogs" action="" method="post">
  42      <?php
  43      choose_primary_blog();
  44      do_action( 'myblogs_allblogs_options' );
  45      ?>
  46      <br clear="all" />
  47      <table class="widefat fixed">
  48      <?php
  49      $settings_html = apply_filters( 'myblogs_options', '', 'global' );
  50      if ( $settings_html != '' ) {
  51          echo "<tr><td valign='top'><h3>" . __( 'Global Settings' ) . "</h3></td><td>";
  52          echo $settings_html;
  53          echo "</td></tr>";
  54      }
  55      reset( $blogs );
  56      $num = count( $blogs );
  57      $cols = 1;
  58      if ( $num >= 20 )
  59          $cols = 4;
  60      elseif ( $num >= 10 )
  61          $cols = 2;
  62      $num_rows = ceil( $num / $cols );
  63      $split = 0;
  64      for ( $i = 1; $i <= $num_rows; $i++ ) {
  65          $rows[] = array_slice( $blogs, $split, $cols );
  66          $split = $split + $cols;
  67      }
  68  
  69      $c = '';
  70      foreach ( $rows as $row ) {
  71          $c = $c == 'alternate' ? '' : 'alternate';
  72          echo "<tr class='$c'>";
  73          $i = 0;
  74          foreach ( $row as $user_blog ) {
  75              $s = $i == 3 ? '' : 'border-right: 1px solid #ccc;';
  76              echo "<td valign='top' style='$s'>";
  77              echo "<h3>{$user_blog->blogname}</h3>";
  78              echo "<p>" . apply_filters( 'myblogs_blog_actions', "<a href='" . esc_url( get_home_url( $user_blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $user_blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
  79              echo apply_filters( 'myblogs_options', '', $user_blog );
  80              echo "</td>";
  81              $i++;
  82          }
  83          echo "</tr>";
  84      }?>
  85      </table>
  86      <input type="hidden" name="action" value="updateblogsettings" />
  87      <?php wp_nonce_field( 'update-my-sites' ); ?>
  88      <p>
  89       <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
  90      </p>
  91      </form>
  92      </div>
  93  <?php
  94  include ( './admin-footer.php' );
  95  ?>


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