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
This commit is contained in:
Sergey Biryukov 2020-06-03 19:55:54 +00:00
parent dfccba8d55
commit f9a4cdcb3c

View File

@ -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 )