From c9e84315821e0865def9d62e43377af6ca9d448e Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 9 Oct 2017 15:22:46 +0000 Subject: [PATCH] Users: Remove some links to the dashboard from My Sites for users who cannot access it. See #41453 Built from https://develop.svn.wordpress.org/trunk@41796 git-svn-id: http://core.svn.wordpress.org/trunk@41630 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/my-sites.php | 17 +++++++++++++++-- wp-includes/admin-bar.php | 33 +++++++++++++++++++++------------ wp-includes/version.php | 2 +- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/wp-admin/my-sites.php b/wp-admin/my-sites.php index a082c2bb16..e07ce7760a 100644 --- a/wp-admin/my-sites.php +++ b/wp-admin/my-sites.php @@ -108,20 +108,33 @@ else : reset( $blogs ); foreach ( $blogs as $user_blog ) { + switch_to_blog( $user_blog->userblog_id ); + echo "
  • "; echo "

    {$user_blog->blogname}

    "; + + $actions = "" . __( 'Visit' ) . ''; + + if ( current_user_can( 'read' ) ) { + $actions .= " | " . __( 'Dashboard' ) . ''; + } + /** * Filters the row links displayed for each site on the My Sites screen. * * @since MU (3.0.0) * - * @param string $string The HTML site link markup. + * @param string $actions The HTML site link markup. * @param object $user_blog An object containing the site data. */ - echo "

    " . apply_filters( 'myblogs_blog_actions', "" . __( 'Visit' ) . " | " . __( 'Dashboard' ) . "", $user_blog ) . "

    "; + $actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog ); + echo "

    " . $actions . '

    '; + /** This filter is documented in wp-admin/my-sites.php */ echo apply_filters( 'myblogs_options', '', $user_blog ); echo "
  • "; + + restore_current_blog(); }?> userblog_id; - $wp_admin_bar->add_menu( array( - 'parent' => 'my-sites-list', - 'id' => $menu_id, - 'title' => $blavatar . $blogname, - 'href' => admin_url(), - ) ); + if ( current_user_can( 'read' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'my-sites-list', + 'id' => $menu_id, + 'title' => $blavatar . $blogname, + 'href' => admin_url(), + ) ); - $wp_admin_bar->add_menu( array( - 'parent' => $menu_id, - 'id' => $menu_id . '-d', - 'title' => __( 'Dashboard' ), - 'href' => admin_url(), - ) ); + $wp_admin_bar->add_menu( array( + 'parent' => $menu_id, + 'id' => $menu_id . '-d', + 'title' => __( 'Dashboard' ), + 'href' => admin_url(), + ) ); + } else { + $wp_admin_bar->add_menu( array( + 'parent' => 'my-sites-list', + 'id' => $menu_id, + 'title' => $blavatar . $blogname, + 'href' => home_url(), + ) ); + } if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { $wp_admin_bar->add_menu( array( diff --git a/wp-includes/version.php b/wp-includes/version.php index 7612a28e8b..eddad65fe4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-beta1-41795'; +$wp_version = '4.9-beta1-41796'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.