wp/wp-admin/my-sites.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     7  * @since 3.0.0
     7  * @since 3.0.0
     8  */
     8  */
     9 
     9 
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 
    11 
    12 if ( !is_multisite() )
    12 if ( ! is_multisite() ) {
    13 	wp_die( __( 'Multisite support is not enabled.' ) );
    13 	wp_die( __( 'Multisite support is not enabled.' ) );
       
    14 }
    14 
    15 
    15 if ( ! current_user_can('read') )
    16 if ( ! current_user_can( 'read' ) ) {
    16 	wp_die( __( 'Sorry, you are not allowed to access this page.' ) );
    17 	wp_die( __( 'Sorry, you are not allowed to access this page.' ) );
       
    18 }
    17 
    19 
    18 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    20 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    19 
    21 
    20 $blogs = get_blogs_of_user( $current_user->ID );
    22 $blogs = get_blogs_of_user( $current_user->ID );
    21 
    23 
    30 	} else {
    32 	} else {
    31 		wp_die( __( 'The primary site you chose does not exist.' ) );
    33 		wp_die( __( 'The primary site you chose does not exist.' ) );
    32 	}
    34 	}
    33 }
    35 }
    34 
    36 
    35 $title = __( 'My Sites' );
    37 $title       = __( 'My Sites' );
    36 $parent_file = 'index.php';
    38 $parent_file = 'index.php';
    37 
    39 
    38 get_current_screen()->add_help_tab( array(
    40 get_current_screen()->add_help_tab(
    39 	'id'      => 'overview',
    41 	array(
    40 	'title'   => __('Overview'),
    42 		'id'      => 'overview',
    41 	'content' =>
    43 		'title'   => __( 'Overview' ),
    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. They can use the links under each site to visit either the front end or the dashboard for that site.') . '</p>'
    44 		'content' =>
    43 ) );
    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 );
    44 
    48 
    45 get_current_screen()->set_help_sidebar(
    49 get_current_screen()->set_help_sidebar(
    46 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    50 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    47 	'<p>' . __('<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>') . '</p>' .
    51 	'<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>' ) . '</p>' .
    48 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    52 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    49 );
    53 );
    50 
    54 
    51 require_once( ABSPATH . 'wp-admin/admin-header.php' );
    55 require_once( ABSPATH . 'wp-admin/admin-header.php' );
    52 
    56 
    53 if ( $updated ) { ?>
    57 if ( $updated ) { ?>
    54 	<div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
    58 	<div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
    55 <?php } ?>
    59 <?php } ?>
    56 
    60 
    57 <div class="wrap">
    61 <div class="wrap">
    58 <h1 class="wp-heading-inline"><?php
    62 <h1 class="wp-heading-inline">
       
    63 <?php
    59 echo esc_html( $title );
    64 echo esc_html( $title );
    60 ?></h1>
    65 ?>
       
    66 </h1>
    61 
    67 
    62 <?php
    68 <?php
    63 if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) {
    69 if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) {
    64 	/** This filter is documented in wp-login.php */
    70 	/** This filter is documented in wp-login.php */
    65 	$sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
    71 	$sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
    69 if ( empty( $blogs ) ) :
    75 if ( empty( $blogs ) ) :
    70 	echo '<p>';
    76 	echo '<p>';
    71 	_e( 'You must be a member of at least one site to use this page.' );
    77 	_e( 'You must be a member of at least one site to use this page.' );
    72 	echo '</p>';
    78 	echo '</p>';
    73 else :
    79 else :
    74 ?>
    80 	?>
    75 
    81 
    76 <hr class="wp-header-end">
    82 <hr class="wp-header-end">
    77 
    83 
    78 <form id="myblogs" method="post">
    84 <form id="myblogs" method="post">
    79 	<?php
    85 	<?php
   108 	reset( $blogs );
   114 	reset( $blogs );
   109 
   115 
   110 	foreach ( $blogs as $user_blog ) {
   116 	foreach ( $blogs as $user_blog ) {
   111 		switch_to_blog( $user_blog->userblog_id );
   117 		switch_to_blog( $user_blog->userblog_id );
   112 
   118 
   113 		echo "<li>";
   119 		echo '<li>';
   114 		echo "<h3>{$user_blog->blogname}</h3>";
   120 		echo "<h3>{$user_blog->blogname}</h3>";
   115 
   121 
   116 		$actions = "<a href='" . esc_url( home_url() ). "'>" . __( 'Visit' ) . '</a>';
   122 		$actions = "<a href='" . esc_url( home_url() ) . "'>" . __( 'Visit' ) . '</a>';
   117 
   123 
   118 		if ( current_user_can( 'read' ) ) {
   124 		if ( current_user_can( 'read' ) ) {
   119 			$actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>';
   125 			$actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>';
   120 		}
   126 		}
   121 
   127 
   130 		$actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
   136 		$actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
   131 		echo "<p class='my-sites-actions'>" . $actions . '</p>';
   137 		echo "<p class='my-sites-actions'>" . $actions . '</p>';
   132 
   138 
   133 		/** This filter is documented in wp-admin/my-sites.php */
   139 		/** This filter is documented in wp-admin/my-sites.php */
   134 		echo apply_filters( 'myblogs_options', '', $user_blog );
   140 		echo apply_filters( 'myblogs_options', '', $user_blog );
   135 		echo "</li>";
   141 		echo '</li>';
   136 
   142 
   137 		restore_current_blog();
   143 		restore_current_blog();
   138 	}?>
   144 	}
       
   145 	?>
   139 	</ul>
   146 	</ul>
   140 	<?php
   147 	<?php
   141 	if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) {
   148 	if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) {
   142 		?><input type="hidden" name="action" value="updateblogsettings" /><?php
   149 		?>
       
   150 		<input type="hidden" name="action" value="updateblogsettings" />
       
   151 		<?php
   143 		wp_nonce_field( 'update-my-sites' );
   152 		wp_nonce_field( 'update-my-sites' );
   144 		submit_button();
   153 		submit_button();
   145 	}
   154 	}
   146 	?>
   155 	?>
   147 	</form>
   156 	</form>