/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( dirname( __FILE__ ) . '/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( __( 'Sorry, you are not allowed to access 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_site( (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. $title = __( 'My Sites' ); 
  34. $parent_file = 'index.php'; 
  35.  
  36. get_current_screen()->add_help_tab( array( 
  37. 'id' => 'overview',  
  38. 'title' => __('Overview'),  
  39. 'content' => 
  40. '<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>' 
  41. ) ); 
  42.  
  43. get_current_screen()->set_help_sidebar( 
  44. '<p><strong>' . __('For more information:') . '</strong></p>' . 
  45. '<p>' . __('<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>') . '</p>' . 
  46. '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' 
  47. ); 
  48.  
  49. require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
  50.  
  51. if ( $updated ) { ?> 
  52. <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div> 
  53. <?php } ?> 
  54.  
  55. <div class="wrap"> 
  56. <h1><?php 
  57. echo esc_html( $title ); 
  58.  
  59. if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) { 
  60. /** This filter is documented in wp-login.php */ 
  61. $sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); 
  62. printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) ); 
  63. ?></h1> 
  64.  
  65. <?php 
  66. if ( empty( $blogs ) ) : 
  67. echo '<p>'; 
  68. _e( 'You must be a member of at least one site to use this page.' ); 
  69. echo '</p>'; 
  70. else : 
  71. ?> 
  72. <form id="myblogs" method="post"> 
  73. <?php 
  74. choose_primary_blog(); 
  75. /** 
  76. * Fires before the sites list on the My Sites screen. 
  77. * 
  78. * @since 3.0.0 
  79. */ 
  80. do_action( 'myblogs_allblogs_options' ); 
  81. ?> 
  82. <br clear="all" /> 
  83. <ul class="my-sites striped"> 
  84. <?php 
  85. /** 
  86. * Enable the Global Settings section on the My Sites screen. 
  87. * 
  88. * By default, the Global Settings section is hidden. Passing a non-empty 
  89. * string to this filter will enable the section, and allow new settings 
  90. * to be added, either globally or for specific sites. 
  91. * 
  92. * @since MU 
  93. * 
  94. * @param string $settings_html The settings HTML markup. Default empty. 
  95. * @param object $context Context of the setting (global or site-specific). Default 'global'. 
  96. */ 
  97. $settings_html = apply_filters( 'myblogs_options', '', 'global' ); 
  98. if ( $settings_html != '' ) { 
  99. echo '<h3>' . __( 'Global Settings' ) . '</h3>'; 
  100. echo $settings_html; 
  101. reset( $blogs ); 
  102.  
  103. foreach ( $blogs as $user_blog ) { 
  104. echo "<li>"; 
  105. echo "<h3>{$user_blog->blogname}</h3>"; 
  106. /** 
  107. * Filters the row links displayed for each site on the My Sites screen. 
  108. * 
  109. * @since MU 
  110. * 
  111. * @param string $string The HTML site link markup. 
  112. * @param object $user_blog An object containing the site data. 
  113. */ 
  114. echo "<p class='my-sites-actions'>" . 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>"; 
  115. /** This filter is documented in wp-admin/my-sites.php */ 
  116. echo apply_filters( 'myblogs_options', '', $user_blog ); 
  117. echo "</li>"; 
  118. }?> 
  119. </ul> 
  120. <?php 
  121. if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) { 
  122. ?><input type="hidden" name="action" value="updateblogsettings" /><?php 
  123. wp_nonce_field( 'update-my-sites' ); 
  124. submit_button(); 
  125. ?> 
  126. </form> 
  127. <?php endif; ?> 
  128. </div> 
  129. <?php 
  130. include( ABSPATH . 'wp-admin/admin-footer.php' ); 
.