| [ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
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 $updated = false; 23 if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) { 24 check_admin_referer( 'update-my-sites' ); 25 26 $blog = get_blog_details( (int) $_POST['primary_blog'] ); 27 if ( $blog && isset( $blog->domain ) ) { 28 update_user_option( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'], true ); 29 $updated = true; 30 } else { 31 wp_die( __( 'The primary site you chose does not exist.' ) ); 32 } 33 } 34 35 $title = __( 'My Sites' ); 36 $parent_file = 'index.php'; 37 38 get_current_screen()->add_help_tab( array( 39 'id' => 'overview', 40 'title' => __('Overview'), 41 'content' => 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 Multisite Network had to be installed separately as WordPress MU (multi-user).') . '</p>' 44 ) ); 45 46 get_current_screen()->set_help_sidebar( 47 '<p><strong>' . __('For more information:') . '</strong></p>' . 48 '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_My_Sites_Screen" target="_blank">Documentation on My Sites</a>') . '</p>' . 49 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 50 ); 51 52 require_once ( './admin-header.php' ); 53 54 if ( $updated ) { ?> 55 <div id="message" class="updated"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div> 56 <?php } ?> 57 58 <div class="wrap"> 59 <?php screen_icon(); ?> 60 <h2><?php echo esc_html( $title ); ?></h2> 61 <?php 62 if ( empty( $blogs ) ) : 63 echo '<p>'; 64 _e( 'You must be a member of at least one site to use this page.' ); 65 echo '</p>'; 66 else : 67 ?> 68 <form id="myblogs" action="" method="post"> 69 <?php 70 choose_primary_blog(); 71 do_action( 'myblogs_allblogs_options' ); 72 ?> 73 <br clear="all" /> 74 <table class="widefat fixed"> 75 <?php 76 $settings_html = apply_filters( 'myblogs_options', '', 'global' ); 77 if ( $settings_html != '' ) { 78 echo '<tr><td valign="top"><h3>' . __( 'Global Settings' ) . '</h3></td><td>'; 79 echo $settings_html; 80 echo '</td></tr>'; 81 } 82 reset( $blogs ); 83 $num = count( $blogs ); 84 $cols = 1; 85 if ( $num >= 20 ) 86 $cols = 4; 87 elseif ( $num >= 10 ) 88 $cols = 2; 89 $num_rows = ceil( $num / $cols ); 90 $split = 0; 91 for ( $i = 1; $i <= $num_rows; $i++ ) { 92 $rows[] = array_slice( $blogs, $split, $cols ); 93 $split = $split + $cols; 94 } 95 96 $c = ''; 97 foreach ( $rows as $row ) { 98 $c = $c == 'alternate' ? '' : 'alternate'; 99 echo "<tr class='$c'>"; 100 $i = 0; 101 foreach ( $row as $user_blog ) { 102 $s = $i == 3 ? '' : 'border-right: 1px solid #ccc;'; 103 echo "<td valign='top' style='$s'>"; 104 echo "<h3>{$user_blog->blogname}</h3>"; 105 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>"; 106 echo apply_filters( 'myblogs_options', '', $user_blog ); 107 echo "</td>"; 108 $i++; 109 } 110 echo "</tr>"; 111 }?> 112 </table> 113 <input type="hidden" name="action" value="updateblogsettings" /> 114 <?php wp_nonce_field( 'update-my-sites' ); ?> 115 <?php submit_button(); ?> 116 </form> 117 <?php endif; ?> 118 </div> 119 <?php 120 include ( './admin-footer.php' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri May 25 03:56:23 2012 | Hosted by follow the white rabbit. |