From 524f1889822820b8cde4f8d945ea72e309658bd0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 3 Jun 2020 19:57:10 +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. Built from https://develop.svn.wordpress.org/trunk@47903 git-svn-id: http://core.svn.wordpress.org/trunk@47677 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/admin-bar.php | 14 ++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 35d1d4c5b9..d38fa62bf4 100644 --- a/wp-includes/admin-bar.php +++ b/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 ) diff --git a/wp-includes/version.php b/wp-includes/version.php index 012ddf9bdb..3deab9667c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47902'; +$wp_version = '5.5-alpha-47903'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.