[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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  __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/forums/">Support forums</a>' ) . '</p>'
  54  );
  55  
  56  require_once  ABSPATH . 'wp-admin/admin-header.php';
  57  
  58  if ( $updated ) {
  59      wp_admin_notice(
  60          '<strong>' . __( 'Settings saved.' ) . '</strong>',
  61          array(
  62              'type'        => 'success',
  63              'dismissible' => true,
  64              'id'          => 'message',
  65          )
  66      );
  67  }
  68  ?>
  69  
  70  <div class="wrap">
  71  <h1 class="wp-heading-inline">
  72  <?php
  73  echo esc_html( $title );
  74  ?>
  75  </h1>
  76  
  77  <?php
  78  if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ), true ) ) {
  79      /** This filter is documented in wp-login.php */
  80      $sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
  81      printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html__( 'Add New Site' ) );
  82  }
  83  
  84  if ( empty( $blogs ) ) :
  85      wp_admin_notice(
  86          '<strong>' . __( 'You must be a member of at least one site to use this page.' ) . '</strong>',
  87          array(
  88              'type'        => 'error',
  89              'dismissible' => true,
  90          )
  91      );
  92      ?>
  93      <?php
  94  else :
  95      ?>
  96  
  97  <hr class="wp-header-end">
  98  
  99  <form id="myblogs" method="post">
 100      <?php
 101      choose_primary_blog();
 102      /**
 103       * Fires before the sites list on the My Sites screen.
 104       *
 105       * @since 3.0.0
 106       */
 107      do_action( 'myblogs_allblogs_options' );
 108      ?>
 109      <br clear="all" />
 110      <ul class="my-sites striped">
 111      <?php
 112      /**
 113       * Filters the settings HTML markup in the Global Settings section on the My Sites screen.
 114       *
 115       * By default, the Global Settings section is hidden. Passing a non-empty
 116       * string to this filter will enable the section, and allow new settings
 117       * to be added, either globally or for specific sites.
 118       *
 119       * @since MU (3.0.0)
 120       *
 121       * @param string $settings_html The settings HTML markup. Default empty.
 122       * @param string $context       Context of the setting (global or site-specific). Default 'global'.
 123       */
 124      $settings_html = apply_filters( 'myblogs_options', '', 'global' );
 125  
 126      if ( $settings_html ) {
 127          echo '<h3>' . __( 'Global Settings' ) . '</h3>';
 128          echo $settings_html;
 129      }
 130  
 131      reset( $blogs );
 132  
 133      foreach ( $blogs as $user_blog ) {
 134          switch_to_blog( $user_blog->userblog_id );
 135  
 136          echo '<li>';
 137          echo "<h3>{$user_blog->blogname}</h3>";
 138  
 139          $actions = "<a href='" . esc_url( home_url() ) . "'>" . __( 'Visit' ) . '</a>';
 140  
 141          if ( current_user_can( 'read' ) ) {
 142              $actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>';
 143          }
 144  
 145          /**
 146           * Filters the row links displayed for each site on the My Sites screen.
 147           *
 148           * @since MU (3.0.0)
 149           *
 150           * @param string $actions   The HTML site link markup.
 151           * @param object $user_blog An object containing the site data.
 152           */
 153          $actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
 154  
 155          echo "<p class='my-sites-actions'>" . $actions . '</p>';
 156  
 157          /** This filter is documented in wp-admin/my-sites.php */
 158          echo apply_filters( 'myblogs_options', '', $user_blog );
 159  
 160          echo '</li>';
 161  
 162          restore_current_blog();
 163      }
 164      ?>
 165      </ul>
 166      <?php
 167      if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) {
 168          ?>
 169          <input type="hidden" name="action" value="updateblogsettings" />
 170          <?php
 171          wp_nonce_field( 'update-my-sites' );
 172          submit_button();
 173      }
 174      ?>
 175      </form>
 176  <?php endif; ?>
 177      </div>
 178  <?php
 179  require_once  ABSPATH . 'wp-admin/admin-footer.php';


Generated : Tue Dec 24 08:20:01 2024 Cross-referenced by PHPXref