[ 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 __DIR__ . '/admin.php'; 11 12 if ( ! is_multisite() ) { 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 } 15 16 if ( ! current_user_can( 'read' ) ) { 17 wp_die( __( 'Sorry, you are not allowed to access this page.' ) ); 18 } 19 20 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash'; 21 22 $blogs = get_blogs_of_user( $current_user->ID ); 23 24 $updated = false; 25 if ( 'updateblogsettings' === $action && isset( $_POST['primary_blog'] ) ) { 26 check_admin_referer( 'update-my-sites' ); 27 28 $blog = get_site( (int) $_POST['primary_blog'] ); 29 if ( $blog && isset( $blog->domain ) ) { 30 update_user_meta( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'] ); 31 $updated = true; 32 } else { 33 wp_die( __( 'The primary site you chose does not exist.' ) ); 34 } 35 } 36 37 // Used in the HTML title tag. 38 $title = __( 'My Sites' ); 39 $parent_file = 'index.php'; 40 41 get_current_screen()->add_help_tab( 42 array( 43 'id' => 'overview', 44 'title' => __( 'Overview' ), 45 'content' => 46 '<p>' . __( 'This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. They can use the links under each site to visit either the front end or the dashboard for that site.' ) . '</p>', 47 ) 48 ); 49 50 get_current_screen()->set_help_sidebar( 51 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 52 '<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>' ) . '</p>' . 53 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' 54 ); 55 56 require_once ABSPATH . 'wp-admin/admin-header.php'; 57 58 if ( $updated ) { ?> 59 <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div> 60 <?php } ?> 61 62 <div class="wrap"> 63 <h1 class="wp-heading-inline"> 64 <?php 65 echo esc_html( $title ); 66 ?> 67 </h1> 68 69 <?php 70 if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ), true ) ) { 71 /** This filter is documented in wp-login.php */ 72 $sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); 73 printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) ); 74 } 75 76 if ( empty( $blogs ) ) : 77 echo '<p>'; 78 _e( 'You must be a member of at least one site to use this page.' ); 79 echo '</p>'; 80 else : 81 ?> 82 83 <hr class="wp-header-end"> 84 85 <form id="myblogs" method="post"> 86 <?php 87 choose_primary_blog(); 88 /** 89 * Fires before the sites list on the My Sites screen. 90 * 91 * @since 3.0.0 92 */ 93 do_action( 'myblogs_allblogs_options' ); 94 ?> 95 <br clear="all" /> 96 <ul class="my-sites striped"> 97 <?php 98 /** 99 * Enable the Global Settings section on the My Sites screen. 100 * 101 * By default, the Global Settings section is hidden. Passing a non-empty 102 * string to this filter will enable the section, and allow new settings 103 * to be added, either globally or for specific sites. 104 * 105 * @since MU (3.0.0) 106 * 107 * @param string $settings_html The settings HTML markup. Default empty. 108 * @param string $context Context of the setting (global or site-specific). Default 'global'. 109 */ 110 $settings_html = apply_filters( 'myblogs_options', '', 'global' ); 111 112 if ( $settings_html ) { 113 echo '<h3>' . __( 'Global Settings' ) . '</h3>'; 114 echo $settings_html; 115 } 116 117 reset( $blogs ); 118 119 foreach ( $blogs as $user_blog ) { 120 switch_to_blog( $user_blog->userblog_id ); 121 122 echo '<li>'; 123 echo "<h3>{$user_blog->blogname}</h3>"; 124 125 $actions = "<a href='" . esc_url( home_url() ) . "'>" . __( 'Visit' ) . '</a>'; 126 127 if ( current_user_can( 'read' ) ) { 128 $actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>'; 129 } 130 131 /** 132 * Filters the row links displayed for each site on the My Sites screen. 133 * 134 * @since MU (3.0.0) 135 * 136 * @param string $actions The HTML site link markup. 137 * @param object $user_blog An object containing the site data. 138 */ 139 $actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog ); 140 141 echo "<p class='my-sites-actions'>" . $actions . '</p>'; 142 143 /** This filter is documented in wp-admin/my-sites.php */ 144 echo apply_filters( 'myblogs_options', '', $user_blog ); 145 146 echo '</li>'; 147 148 restore_current_blog(); 149 } 150 ?> 151 </ul> 152 <?php 153 if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) { 154 ?> 155 <input type="hidden" name="action" value="updateblogsettings" /> 156 <?php 157 wp_nonce_field( 'update-my-sites' ); 158 submit_button(); 159 } 160 ?> 161 </form> 162 <?php endif; ?> 163 </div> 164 <?php 165 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |