[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/ -> my-sites.php (source)

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


Generated: Sun Sep 22 01:00:03 2019 Cross-referenced by PHPXref 0.7.1