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. git-svn-id: https://develop.svn.wordpress.org/trunk@48050 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
00c0913c1f
commit
1d5e59c538
@ -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 ) {
|
switch ( $action ) {
|
||||||
|
|
||||||
case 'editcomment':
|
case 'editcomment':
|
||||||
@ -60,9 +70,6 @@ switch ( $action ) {
|
|||||||
wp_enqueue_script( 'comment' );
|
wp_enqueue_script( 'comment' );
|
||||||
require_once ABSPATH . 'wp-admin/admin-header.php';
|
require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||||
|
|
||||||
$comment_id = absint( $_GET['c'] );
|
|
||||||
|
|
||||||
$comment = get_comment( $comment_id );
|
|
||||||
if ( ! $comment ) {
|
if ( ! $comment ) {
|
||||||
comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
|
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':
|
case 'spam':
|
||||||
$title = __( 'Moderate Comment' );
|
$title = __( 'Moderate Comment' );
|
||||||
|
|
||||||
$comment_id = absint( $_GET['c'] );
|
|
||||||
|
|
||||||
$comment = get_comment( $comment_id );
|
|
||||||
if ( ! $comment ) {
|
if ( ! $comment ) {
|
||||||
wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
|
wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
|
||||||
die();
|
die();
|
||||||
|
@ -75,17 +75,17 @@
|
|||||||
border-right: 5px solid transparent;
|
border-right: 5px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-response .post-com-count-approved:hover .comment-count-approved,
|
.column-response a.post-com-count-approved:hover .comment-count-approved,
|
||||||
.column-response .post-com-count-approved:focus .comment-count-approved,
|
.column-response a.post-com-count-approved:focus .comment-count-approved,
|
||||||
.column-comments .post-com-count-approved:hover .comment-count-approved,
|
.column-comments a.post-com-count-approved:hover .comment-count-approved,
|
||||||
.column-comments .post-com-count-approved:focus .comment-count-approved {
|
.column-comments a.post-com-count-approved:focus .comment-count-approved {
|
||||||
background: #0073aa;
|
background: #0073aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-response .post-com-count-approved:hover:after,
|
.column-response a.post-com-count-approved:hover:after,
|
||||||
.column-response .post-com-count-approved:focus:after,
|
.column-response a.post-com-count-approved:focus:after,
|
||||||
.column-comments .post-com-count-approved:hover:after,
|
.column-comments a.post-com-count-approved:hover:after,
|
||||||
.column-comments .post-com-count-approved:focus:after {
|
.column-comments a.post-com-count-approved:focus:after {
|
||||||
border-top-color: #0073aa;
|
border-top-color: #0073aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,14 +682,21 @@ class WP_List_Table {
|
|||||||
$pending_comments_number
|
$pending_comments_number
|
||||||
);
|
);
|
||||||
|
|
||||||
// No comments at all.
|
|
||||||
if ( ! $approved_comments && ! $pending_comments ) {
|
if ( ! $approved_comments && ! $pending_comments ) {
|
||||||
|
// No comments at all.
|
||||||
printf(
|
printf(
|
||||||
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
||||||
__( 'No comments' )
|
__( '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 ) {
|
} elseif ( $approved_comments ) {
|
||||||
|
// Link the comment bubble to approved comments.
|
||||||
printf(
|
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>',
|
'<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(
|
esc_url(
|
||||||
@ -705,6 +712,7 @@ class WP_List_Table {
|
|||||||
$pending_comments ? $approved_phrase : $approved_only_phrase
|
$pending_comments ? $approved_phrase : $approved_only_phrase
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// Don't link the comment bubble when there are no approved comments.
|
||||||
printf(
|
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>',
|
'<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,
|
$approved_comments_number,
|
||||||
|
Loading…
Reference in New Issue
Block a user