]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/my-sites.php
Wordpress 3.0.1
[autoinstalls/wordpress.git] / wp-admin / my-sites.php
1 <?php
2 /**
3  * My Sites dashboard.
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.0.0
8  */
9
10 require_once( './admin.php' );
11
12 if ( !is_multisite() )
13         wp_die( __( 'Multisite support is not enabled.' ) );
14
15 if ( ! current_user_can('read') )
16         wp_die( __( 'You do not have sufficient permissions to view this page.' ) );
17
18 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
19
20 $blogs = get_blogs_of_user( $current_user->id );
21
22 if ( empty( $blogs ) )
23         wp_die( __( 'You must be a member of at least one site to use this page.' ) );
24
25 $updated = false;
26 if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
27         check_admin_referer( 'update-my-sites' );
28
29         $blog = get_blog_details( (int) $_POST['primary_blog'] );
30         if ( $blog && isset( $blog->domain ) ) {
31                 update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
32                 $updated = true;
33         } else {
34                 wp_die( __( 'The primary site you chose does not exist.' ) );
35         }
36 }
37
38 $title = __( 'My Sites' );
39 $parent_file = 'index.php';
40
41 add_contextual_help($current_screen,
42         '<p>' . __('This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. He or she can use the links under each site to visit either the frontend or the dashboard for that site.') . '</p>' .
43         '<p>' . __('Up until WordPress version 3.0, what is now called a Multi-site Network had to be installed separately as WordPress MU (multi-user).') . '</p>' .
44         '<p><strong>' . __('For more information:') . '</strong></p>' .
45         '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_My_Sites_SubPanel" target="_blank">My Sites Documentation</a>') . '</p>' .
46         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
47 );
48
49 require_once( './admin-header.php' );
50
51 if ( $updated ) { ?>
52         <div id="message" class="updated"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
53 <?php } ?>
54
55 <div class="wrap">
56 <?php screen_icon(); ?>
57 <h2><?php echo esc_html( $title ); ?></h2>
58 <form id="myblogs" action="" method="post">
59         <?php
60         choose_primary_blog();
61         do_action( 'myblogs_allblogs_options' );
62         ?>
63         <br clear="all" />
64         <table class="widefat fixed">
65         <?php
66         $settings_html = apply_filters( 'myblogs_options', '', 'global' );
67         if ( $settings_html != '' ) {
68                 echo '<tr><td valign="top"><h3>' . __( 'Global Settings' ) . '</h3></td><td>';
69                 echo $settings_html;
70                 echo '</td></tr>';
71         }
72         reset( $blogs );
73         $num = count( $blogs );
74         $cols = 1;
75         if ( $num >= 20 )
76                 $cols = 4;
77         elseif ( $num >= 10 )
78                 $cols = 2;
79         $num_rows = ceil( $num / $cols );
80         $split = 0;
81         for ( $i = 1; $i <= $num_rows; $i++ ) {
82                 $rows[] = array_slice( $blogs, $split, $cols );
83                 $split = $split + $cols;
84         }
85
86         $c = '';
87         foreach ( $rows as $row ) {
88                 $c = $c == 'alternate' ? '' : 'alternate';
89                 echo "<tr class='$c'>";
90                 $i = 0;
91                 foreach ( $row as $user_blog ) {
92                         $s = $i == 3 ? '' : 'border-right: 1px solid #ccc;';
93                         echo "<td valign='top' style='$s'>";
94                         echo "<h3>{$user_blog->blogname}</h3>";
95                         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>";
96                         echo apply_filters( 'myblogs_options', '', $user_blog );
97                         echo "</td>";
98                         $i++;
99                 }
100                 echo "</tr>";
101         }?>
102         </table>
103         <input type="hidden" name="action" value="updateblogsettings" />
104         <?php wp_nonce_field( 'update-my-sites' ); ?>
105         <p>
106          <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
107         </p>
108         </form>
109         </div>
110 <?php
111 include( './admin-footer.php' );
112 ?>