From a9042cad2d0ece03f66a3412c5019c11e1253521 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 29 Nov 2010 16:07:32 +0000 Subject: [PATCH] Admin Bar: Don't show Manage Comments and Add Post link if the user doesn't has the cap for it. Props ocean90. fixes #15597 git-svn-id: https://develop.svn.wordpress.org/trunk@16609 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/admin-bar.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index b384327fc9..1236d16e97 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -135,9 +135,12 @@ function wp_admin_bar_my_sites_menu() { if ( ! isset( $blog->visible ) || $blog->visible === true ) { $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => get_admin_url($blog->userblog_id), ) ); $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => get_admin_url($blog->userblog_id), ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url($blog->userblog_id, 'post-new.php'), ) ); - $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php'), ) ); + if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) { + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url($blog->userblog_id, 'post-new.php'), ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php'), ) ); + } + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Visit Site' ), 'href' => get_home_url($blog->userblog_id), ) ); } }