Skip to content

Commit bf9f231

Browse files
authored
Comment: Redirect uneditable comments to the right list (#1896)
1 parent 1582c1f commit bf9f231

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

includes/wp-admin/class-admin.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,26 @@ function ( $all_caps, $caps, $arg ) {
272272
);
273273

274274
// phpcs:ignore WordPress.Security.NonceVerification
275-
if ( Comment::was_received( absint( $_GET['c'] ?? 0 ) ) ) {
276-
// Redirect to the pending comments page.
277-
\wp_safe_redirect( \admin_url( 'edit-comments.php?comment_status=moderated' ) );
275+
$comment_id = \absint( $_GET['c'] ?? 0 );
276+
if ( Comment::was_received( $comment_id ) ) {
277+
$path = 'edit-comments.php';
278+
279+
switch ( \wp_get_comment_status( $comment_id ) ) { // phpcs:ignore WordPress.Security.NonceVerification
280+
case 'spam':
281+
$path = 'edit-comments.php?comment_status=spam';
282+
break;
283+
284+
case 'trash':
285+
$path = 'edit-comments.php?comment_status=trash';
286+
break;
287+
288+
case 'unapproved':
289+
$path = 'edit-comments.php?comment_status=moderated';
290+
break;
291+
}
292+
293+
// Redirect to the appropriate comments page.
294+
\wp_safe_redirect( \admin_url( $path ) );
278295
exit;
279296
}
280297
}

0 commit comments

Comments
 (0)