Comments: Don't display edit links to trashed post comments.

If a post is in the trash, the comments bubble won't link to the comments list.

Fixes: #37826.
Props: swissspidy, helen, FolioVision, DrewAPicture, stevenlinx, donmhico, birgire, garrett-eclipse, andraganescu, johnbillion. 



Built from https://develop.svn.wordpress.org/trunk@48050


git-svn-id: http://core.svn.wordpress.org/trunk@47817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-06-15 23:06:08 +00:00
parent 6aa5788189
commit 28d29b35f7
7 changed files with 39 additions and 27 deletions

View File

@ -36,6 +36,16 @@ if ( isset( $_GET['dt'] ) ) {
}
}
// Prevent actions on a comment associated with a trashed post.
$comment_id = absint( $_GET['c'] );
$comment = get_comment( $comment_id );
if ( 'trash' === get_post_status( $comment->comment_post_ID ) ) {
wp_die(
__( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' )
);
}
switch ( $action ) {
case 'editcomment':
@ -60,9 +70,6 @@ switch ( $action ) {
wp_enqueue_script( 'comment' );
require_once ABSPATH . 'wp-admin/admin-header.php';
$comment_id = absint( $_GET['c'] );
$comment = get_comment( $comment_id );
if ( ! $comment ) {
comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
}
@ -87,9 +94,6 @@ switch ( $action ) {
case 'spam':
$title = __( 'Moderate Comment' );
$comment_id = absint( $_GET['c'] );
$comment = get_comment( $comment_id );
if ( ! $comment ) {
wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
die();

View File

@ -76,17 +76,17 @@
border-left: 5px solid transparent;
}
.column-response .post-com-count-approved:hover .comment-count-approved,
.column-response .post-com-count-approved:focus .comment-count-approved,
.column-comments .post-com-count-approved:hover .comment-count-approved,
.column-comments .post-com-count-approved:focus .comment-count-approved {
.column-response a.post-com-count-approved:hover .comment-count-approved,
.column-response a.post-com-count-approved:focus .comment-count-approved,
.column-comments a.post-com-count-approved:hover .comment-count-approved,
.column-comments a.post-com-count-approved:focus .comment-count-approved {
background: #0073aa;
}
.column-response .post-com-count-approved:hover:after,
.column-response .post-com-count-approved:focus:after,
.column-comments .post-com-count-approved:hover:after,
.column-comments .post-com-count-approved:focus:after {
.column-response a.post-com-count-approved:hover:after,
.column-response a.post-com-count-approved:focus:after,
.column-comments a.post-com-count-approved:hover:after,
.column-comments a.post-com-count-approved:focus:after {
border-top-color: #0073aa;
}

File diff suppressed because one or more lines are too long

View File

@ -75,17 +75,17 @@
border-right: 5px solid transparent;
}
.column-response .post-com-count-approved:hover .comment-count-approved,
.column-response .post-com-count-approved:focus .comment-count-approved,
.column-comments .post-com-count-approved:hover .comment-count-approved,
.column-comments .post-com-count-approved:focus .comment-count-approved {
.column-response a.post-com-count-approved:hover .comment-count-approved,
.column-response a.post-com-count-approved:focus .comment-count-approved,
.column-comments a.post-com-count-approved:hover .comment-count-approved,
.column-comments a.post-com-count-approved:focus .comment-count-approved {
background: #0073aa;
}
.column-response .post-com-count-approved:hover:after,
.column-response .post-com-count-approved:focus:after,
.column-comments .post-com-count-approved:hover:after,
.column-comments .post-com-count-approved:focus:after {
.column-response a.post-com-count-approved:hover:after,
.column-response a.post-com-count-approved:focus:after,
.column-comments a.post-com-count-approved:hover:after,
.column-comments a.post-com-count-approved:focus:after {
border-top-color: #0073aa;
}

File diff suppressed because one or more lines are too long

View File

@ -682,14 +682,21 @@ class WP_List_Table {
$pending_comments_number
);
// No comments at all.
if ( ! $approved_comments && ! $pending_comments ) {
// No comments at all.
printf(
'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
__( 'No comments' )
);
// Approved comments have different display depending on some conditions.
} elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
// Don't link the comment bubble for a trashed post.
printf(
'<span class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
$approved_comments_number,
$pending_comments ? $approved_phrase : $approved_only_phrase
);
} elseif ( $approved_comments ) {
// Link the comment bubble to approved comments.
printf(
'<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
esc_url(
@ -705,6 +712,7 @@ class WP_List_Table {
$pending_comments ? $approved_phrase : $approved_only_phrase
);
} else {
// Don't link the comment bubble when there are no approved comments.
printf(
'<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
$approved_comments_number,

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48049';
$wp_version = '5.5-alpha-48050';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.