WordPress.org

Make WordPress Core

Ticket #36208: 36208.4.diff

File 36208.4.diff, 1.1 KB (added by donmhico, 10 months ago)
  • src/wp-admin/includes/class-wp-comments-list-table.php

    diff --git src/wp-admin/includes/class-wp-comments-list-table.php src/wp-admin/includes/class-wp-comments-list-table.php
    index a11eefc873..206e1b6823 100644
    class WP_Comments_List_Table extends WP_List_Table { 
    538538        }
    539539
    540540        /**
     541         * @since 5.4.0 Do not display comments for post types that are no longer registered.
     542         *
    541543         * @global WP_Post    $post    Global post object.
    542544         * @global WP_Comment $comment Global comment object.
    543545         *
    class WP_Comments_List_Table extends WP_List_Table { 
    557559                if ( $comment->comment_post_ID > 0 ) {
    558560                        $post = get_post( $comment->comment_post_ID );
    559561                }
     562
     563                // Check if post type exists or not
     564                $post_type_object = get_post_type_object( $post->post_type );
     565
     566                // Early exit, if the post type doesn't exists.
     567                if ( null === $post_type_object ) {
     568                        return;
     569                }
     570
    560571                $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
    561572
    562573                echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";