Skip to content

Commit 69b036b

Browse files
committed
Fix trashing/untrashing comments when no JS, props caesarsgrunt, see WordPress#4529
git-svn-id: https://develop.svn.wordpress.org/trunk@12113 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5e11e93 commit 69b036b

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

wp-admin/comment.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,33 +171,36 @@ function comment_footer_die( $msg ) {
171171
$comment_id = absint( $_REQUEST['c'] );
172172
$noredir = isset($_REQUEST['noredir']);
173173

174-
if (!$comment = get_comment($comment_id))
174+
if ( !$comment = get_comment($comment_id) )
175175
comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
176-
if (!current_user_can('edit_post', $comment->comment_post_ID ))
176+
if ( !current_user_can('edit_post', $comment->comment_post_ID ) )
177177
comment_footer_die( __('You are not allowed to edit comments on this post.') );
178178

179-
if ($action == 'trashcomment') {
180-
check_admin_referer( 'trash-comment_' . $comment_id );
179+
check_admin_referer( 'delete-comment_' . $comment_id );
180+
181+
if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') )
182+
$redir = wp_get_referer();
183+
elseif ( '' != wp_get_original_referer() && false == $noredir )
184+
$redir = wp_get_original_referer();
185+
else
186+
$redir = admin_url('edit-comments.php');
187+
188+
if ( $action == 'trashcomment' ) {
181189
wp_trash_comment($comment_id);
182-
}
183-
else {
184-
check_admin_referer( 'untrash-comment_' . $comment_id );
190+
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
191+
} else {
185192
wp_untrash_comment($comment_id);
193+
$redir = add_query_arg( array('untrashed' => '1'), $redir );
186194
}
187195

188-
if ('' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ))
189-
wp_redirect( wp_get_referer() );
190-
else if ('' != wp_get_original_referer() && false == $noredir)
191-
wp_redirect(wp_get_original_referer());
192-
else
193-
wp_redirect(admin_url('edit-comments.php'));
196+
wp_redirect( $redir );
194197

195198
die;
196199
break;
197200

198201
case 'unapprovecomment' :
199202
$comment_id = absint( $_GET['c'] );
200-
check_admin_referer( 'unapprove-comment_' . $comment_id );
203+
check_admin_referer( 'approve-comment_' . $comment_id );
201204

202205
if ( isset( $_GET['noredir'] ) )
203206
$noredir = true;

wp-admin/edit-form-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
<div id="major-publishing-actions">
7070
<div id="delete-action">
71-
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=trashcomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'trash-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
71+
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=trashcomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
7272
</div>
7373
<div id="publishing-action">
7474
<input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />

0 commit comments

Comments
 (0)