Comments: Use post_password_required() for comment capability checks.

Follow-up to [56836], [57123].

Fixes #59929.

git-svn-id: https://develop.svn.wordpress.org/trunk@57285 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2024-01-15 17:40:06 +00:00
parent ba40e28093
commit 56e16bda31
3 changed files with 3 additions and 5 deletions

View File

@ -648,7 +648,7 @@ class WP_Comments_List_Table extends WP_List_Table {
$edit_post_cap = $post ? 'edit_post' : 'edit_posts';
if ( ! current_user_can( $edit_post_cap, $comment->comment_post_ID )
&& ( ! empty( $post->post_password )
&& ( post_password_required( $comment->comment_post_ID )
|| ! current_user_can( 'read_post', $comment->comment_post_ID ) )
) {
// The user has no access to the post and thus cannot see the comments.

View File

@ -832,7 +832,7 @@ class WP_List_Table {
$edit_post_cap = $post_object ? 'edit_post' : 'edit_posts';
if ( ! current_user_can( $edit_post_cap, $post_id )
&& ( ! empty( $post_object->post_password )
&& ( post_password_required( $post_id )
|| ! current_user_can( 'read_post', $post_id ) )
) {
// The user has no access to the post and thus cannot see the comments.

View File

@ -1088,10 +1088,8 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
}
foreach ( $possible as $comment ) {
$comment_post = get_post( $comment->comment_post_ID );
if ( ! current_user_can( 'edit_post', $comment->comment_post_ID )
&& ( ! empty( $comment_post->post_password )
&& ( post_password_required( $comment->comment_post_ID )
|| ! current_user_can( 'read_post', $comment->comment_post_ID ) )
) {
// The user has no access to the post and thus cannot see the comments.