From 195e473fe4573cc78f5bb1def976c927a24b68f1 Mon Sep 17 00:00:00 2001 From: azaozz Date: Tue, 27 Oct 2009 03:46:31 +0000 Subject: [PATCH] Fix trashing/untrashing comments when no JS, props caesarsgrunt, see #4529 git-svn-id: http://svn.automattic.com/wordpress/trunk@12113 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/comment.php | 31 +++++++++++++++++-------------- wp-admin/edit-form-comment.php | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/wp-admin/comment.php b/wp-admin/comment.php index 4bfe2e2310..fe1609efb1 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -171,33 +171,36 @@ case 'untrashcomment' : $comment_id = absint( $_REQUEST['c'] ); $noredir = isset($_REQUEST['noredir']); - if (!$comment = get_comment($comment_id)) + if ( !$comment = get_comment($comment_id) ) comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit-comments.php') ); - if (!current_user_can('edit_post', $comment->comment_post_ID )) + if ( !current_user_can('edit_post', $comment->comment_post_ID ) ) comment_footer_die( __('You are not allowed to edit comments on this post.') ); - if ($action == 'trashcomment') { - check_admin_referer( 'trash-comment_' . $comment_id ); + check_admin_referer( 'delete-comment_' . $comment_id ); + + if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') ) + $redir = wp_get_referer(); + elseif ( '' != wp_get_original_referer() && false == $noredir ) + $redir = wp_get_original_referer(); + else + $redir = admin_url('edit-comments.php'); + + if ( $action == 'trashcomment' ) { wp_trash_comment($comment_id); - } - else { - check_admin_referer( 'untrash-comment_' . $comment_id ); + $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); + } else { wp_untrash_comment($comment_id); + $redir = add_query_arg( array('untrashed' => '1'), $redir ); } - if ('' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' )) - wp_redirect( wp_get_referer() ); - else if ('' != wp_get_original_referer() && false == $noredir) - wp_redirect(wp_get_original_referer()); - else - wp_redirect(admin_url('edit-comments.php')); + wp_redirect( $redir ); die; break; case 'unapprovecomment' : $comment_id = absint( $_GET['c'] ); - check_admin_referer( 'unapprove-comment_' . $comment_id ); + check_admin_referer( 'approve-comment_' . $comment_id ); if ( isset( $_GET['noredir'] ) ) $noredir = true; diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php index edcb1c8d5a..2c09b93c93 100644 --- a/wp-admin/edit-form-comment.php +++ b/wp-admin/edit-form-comment.php @@ -68,7 +68,7 @@ $date = date_i18n( $datef, strtotime( $comment->comment_date ) );
-comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'trash-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "\n"; ?> +comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "\n"; ?>