wp/wp-admin/my-sites.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Multisite
     6  * @subpackage Multisite
     7  * @since 3.0.0
     7  * @since 3.0.0
     8  */
     8  */
     9 
     9 
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once __DIR__ . '/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 
    20 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    20 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    21 
    21 
    22 $blogs = get_blogs_of_user( $current_user->ID );
    22 $blogs = get_blogs_of_user( $current_user->ID );
    23 
    23 
    24 $updated = false;
    24 $updated = false;
    25 if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
    25 if ( 'updateblogsettings' === $action && isset( $_POST['primary_blog'] ) ) {
    26 	check_admin_referer( 'update-my-sites' );
    26 	check_admin_referer( 'update-my-sites' );
    27 
    27 
    28 	$blog = get_site( (int) $_POST['primary_blog'] );
    28 	$blog = get_site( (int) $_POST['primary_blog'] );
    29 	if ( $blog && isset( $blog->domain ) ) {
    29 	if ( $blog && isset( $blog->domain ) ) {
    30 		update_user_option( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'], true );
    30 		update_user_option( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'], true );
    50 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    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>' .
    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>'
    52 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    53 );
    53 );
    54 
    54 
    55 require_once( ABSPATH . 'wp-admin/admin-header.php' );
    55 require_once ABSPATH . 'wp-admin/admin-header.php';
    56 
    56 
    57 if ( $updated ) { ?>
    57 if ( $updated ) { ?>
    58 	<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>
    59 <?php } ?>
    59 <?php } ?>
    60 
    60 
    64 echo esc_html( $title );
    64 echo esc_html( $title );
    65 ?>
    65 ?>
    66 </h1>
    66 </h1>
    67 
    67 
    68 <?php
    68 <?php
    69 if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) {
    69 if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ), true ) ) {
    70 	/** This filter is documented in wp-login.php */
    70 	/** This filter is documented in wp-login.php */
    71 	$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' ) );
    72 	printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) );
    72 	printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) );
    73 }
    73 }
    74 
    74 
   102 	 * to be added, either globally or for specific sites.
   102 	 * to be added, either globally or for specific sites.
   103 	 *
   103 	 *
   104 	 * @since MU (3.0.0)
   104 	 * @since MU (3.0.0)
   105 	 *
   105 	 *
   106 	 * @param string $settings_html The settings HTML markup. Default empty.
   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'.
   107 	 * @param string $context       Context of the setting (global or site-specific). Default 'global'.
   108 	 */
   108 	 */
   109 	$settings_html = apply_filters( 'myblogs_options', '', 'global' );
   109 	$settings_html = apply_filters( 'myblogs_options', '', 'global' );
   110 	if ( $settings_html != '' ) {
   110 
       
   111 	if ( $settings_html ) {
   111 		echo '<h3>' . __( 'Global Settings' ) . '</h3>';
   112 		echo '<h3>' . __( 'Global Settings' ) . '</h3>';
   112 		echo $settings_html;
   113 		echo $settings_html;
   113 	}
   114 	}
       
   115 
   114 	reset( $blogs );
   116 	reset( $blogs );
   115 
   117 
   116 	foreach ( $blogs as $user_blog ) {
   118 	foreach ( $blogs as $user_blog ) {
   117 		switch_to_blog( $user_blog->userblog_id );
   119 		switch_to_blog( $user_blog->userblog_id );
   118 
   120 
   132 		 *
   134 		 *
   133 		 * @param string $actions   The HTML site link markup.
   135 		 * @param string $actions   The HTML site link markup.
   134 		 * @param object $user_blog An object containing the site data.
   136 		 * @param object $user_blog An object containing the site data.
   135 		 */
   137 		 */
   136 		$actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
   138 		$actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
       
   139 
   137 		echo "<p class='my-sites-actions'>" . $actions . '</p>';
   140 		echo "<p class='my-sites-actions'>" . $actions . '</p>';
   138 
   141 
   139 		/** This filter is documented in wp-admin/my-sites.php */
   142 		/** This filter is documented in wp-admin/my-sites.php */
   140 		echo apply_filters( 'myblogs_options', '', $user_blog );
   143 		echo apply_filters( 'myblogs_options', '', $user_blog );
       
   144 
   141 		echo '</li>';
   145 		echo '</li>';
   142 
   146 
   143 		restore_current_blog();
   147 		restore_current_blog();
   144 	}
   148 	}
   145 	?>
   149 	?>
   155 	?>
   159 	?>
   156 	</form>
   160 	</form>
   157 <?php endif; ?>
   161 <?php endif; ?>
   158 	</div>
   162 	</div>
   159 <?php
   163 <?php
   160 include( ABSPATH . 'wp-admin/admin-footer.php' );
   164 require_once ABSPATH . 'wp-admin/admin-footer.php';