Make WordPress Core

Changeset 56836

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

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

Props peterwilsoncc, jorbin, audrasjb.

Location:
trunk/src/wp-admin/includes
Files:
3 edited

Legend:

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

    r56747 r56836  
    654654
    655655        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
     656
     657
     658
     659
     660
     661
     662
     663
     664
     665
     666
     667
     668
    656669
    657670        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r56665 r56836  
    851851            $pending_comments_number
    852852        );
     853
     854
     855
     856
     857
     858
     859
     860
     861
     862
     863
     864
     865
     866
    853867
    854868        if ( ! $approved_comments && ! $pending_comments ) {
  • trunk/src/wp-admin/includes/dashboard.php

    r56697 r56836  
    11101110        echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
    11111111        foreach ( $comments as $comment ) {
    1112             _wp_dashboard_recent_comments_row( $comment );
     1112            $comment_post = get_post( $comment->comment_post_ID );
     1113            if (
     1114                current_user_can( 'edit_post', $comment->comment_post_ID ) ||
     1115                (
     1116                    empty( $comment_post->post_password ) &&
     1117                    current_user_can( 'read_post', $comment->comment_post_ID )
     1118                )
     1119            ) {
     1120                _wp_dashboard_recent_comments_row( $comment );
     1121            }
    11131122        }
    11141123        echo '</ul>';
Note: See TracChangeset for help on using the changeset viewer.