Make WordPress Core


Ignore:
Timestamp:
10/12/2023 12:36:29 PM (9 months ago)
Author:
audrasjb
Message:

Comments: Prevent users who can not see a post from seeing comments on it.

Props peterwilsoncc, jorbin, audrasjb.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r56665 r56836  
    851851            $pending_comments_number
    852852        );
     853
     854        $post_object   = get_post( $post_id );
     855        $edit_post_cap = $post_object ? 'edit_post' : 'edit_posts';
     856        if (
     857            current_user_can( $edit_post_cap, $post_id ) ||
     858            (
     859                empty( $post_object->post_password ) &&
     860                current_user_can( 'read_post', $post_id )
     861            )
     862        ) {
     863            // The user has access to the post and thus can see comments
     864        } else {
     865            return false;
     866        }
    853867
    854868        if ( ! $approved_comments && ! $pending_comments ) {
Note: See TracChangeset for help on using the changeset viewer.