From f9a4cdcb3cf85c486f7c3badf5e2d423a96784d7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 3 Jun 2020 19:55:54 +0000 Subject: [PATCH] Toolbar: Display a "View Post" link when viewing comments for a single post on Comments screen. Props Otto42, matt, SergeyBiryukov. Fixes #50312. git-svn-id: https://develop.svn.wordpress.org/trunk@47903 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/admin-bar.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 35d1d4c5b9..d38fa62bf4 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -696,19 +696,25 @@ function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { * @param WP_Admin_Bar $wp_admin_bar */ function wp_admin_bar_edit_menu( $wp_admin_bar ) { - global $tag, $wp_the_query, $user_id; + global $tag, $wp_the_query, $user_id, $post_id; if ( is_admin() ) { - $current_screen = get_current_screen(); - $post = get_post(); + $current_screen = get_current_screen(); + $post = get_post(); + $post_type_object = null; if ( 'post' === $current_screen->base ) { $post_type_object = get_post_type_object( $post->post_type ); } elseif ( 'edit' === $current_screen->base ) { $post_type_object = get_post_type_object( $current_screen->post_type ); + } elseif ( 'edit-comments' === $current_screen->base && $post_id ) { + $post = get_post( $post_id ); + if ( $post ) { + $post_type_object = get_post_type_object( $post->post_type ); + } } - if ( 'post' === $current_screen->base + if ( ( 'post' === $current_screen->base || 'edit-comments' === $current_screen->base ) && 'add' !== $current_screen->action && ( $post_type_object ) && current_user_can( 'read_post', $post->ID )