Make WordPress Core


Ignore:
Timestamp:
06/03/2020 07:55:54 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Toolbar: Display a "View Post" link when viewing comments for a single post on Comments screen.

Props Otto42, matt, SergeyBiryukov.
Fixes #50312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r47808 r47903  
    697697 */
    698698function wp_admin_bar_edit_menu( $wp_admin_bar ) {
    699     global $tag, $wp_the_query, $user_id;
     699    global $tag, $wp_the_query, $user_id, $post_id;
    700700
    701701    if ( is_admin() ) {
    702         $current_screen = get_current_screen();
    703         $post           = get_post();
     702        $current_screen   = get_current_screen();
     703        $post             = get_post();
     704        $post_type_object = null;
    704705
    705706        if ( 'post' === $current_screen->base ) {
     
    707708        } elseif ( 'edit' === $current_screen->base ) {
    708709            $post_type_object = get_post_type_object( $current_screen->post_type );
    709         }
    710 
    711         if ( 'post' === $current_screen->base
     710        } elseif ( 'edit-comments' === $current_screen->base && $post_id ) {
     711            $post = get_post( $post_id );
     712            if ( $post ) {
     713                $post_type_object = get_post_type_object( $post->post_type );
     714            }
     715        }
     716
     717        if ( ( 'post' === $current_screen->base || 'edit-comments' === $current_screen->base )
    712718            && 'add' !== $current_screen->action
    713719            && ( $post_type_object )
Note: See TracChangeset for help on using the changeset viewer.