<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12113] trunk/wp-admin: Fix trashing/untrashing comments when no JS,
props caesarsgrunt, see #4529</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12113">12113</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2009-10-27 03:46:31 +0000 (Tue, 27 Oct 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix trashing/untrashing comments when no JS, props caesarsgrunt, see <a href="http://trac.wordpress.org/ticket/4529">#4529</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincommentphp">trunk/wp-admin/comment.php</a></li>
<li><a href="#trunkwpadmineditformcommentphp">trunk/wp-admin/edit-form-comment.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/comment.php (12112 => 12113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/comment.php        2009-10-27 00:23:58 UTC (rev 12112)
+++ trunk/wp-admin/comment.php        2009-10-27 03:46:31 UTC (rev 12113)
</span><span class="lines">@@ -171,33 +171,36 @@
</span><span class="cx">         $comment_id = absint( $_REQUEST['c'] );
</span><span class="cx">         $noredir = isset($_REQUEST['noredir']);
</span><span class="cx">
</span><del>-        if (!$comment = get_comment($comment_id))
</del><ins>+        if ( !$comment = get_comment($comment_id) )
</ins><span class="cx">                 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
</span><del>-        if (!current_user_can('edit_post', $comment->comment_post_ID ))
</del><ins>+        if ( !current_user_can('edit_post', $comment->comment_post_ID ) )
</ins><span class="cx">                 comment_footer_die( __('You are not allowed to edit comments on this post.') );
</span><span class="cx">
</span><del>-        if ($action == 'trashcomment') {
-                check_admin_referer( 'trash-comment_' . $comment_id );
</del><ins>+        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' ) {
</ins><span class="cx">                 wp_trash_comment($comment_id);
</span><del>-        }
-        else {
-                check_admin_referer( 'untrash-comment_' . $comment_id );
</del><ins>+                $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
+        } else {
</ins><span class="cx">                 wp_untrash_comment($comment_id);
</span><ins>+                $redir = add_query_arg( array('untrashed' => '1'), $redir );
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        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'));
</del><ins>+        wp_redirect( $redir );
</ins><span class="cx">
</span><span class="cx">         die;
</span><span class="cx">         break;
</span><span class="cx">
</span><span class="cx"> case 'unapprovecomment' :
</span><span class="cx">         $comment_id = absint( $_GET['c'] );
</span><del>-        check_admin_referer( 'unapprove-comment_' . $comment_id );
</del><ins>+        check_admin_referer( 'approve-comment_' . $comment_id );
</ins><span class="cx">
</span><span class="cx">         if ( isset( $_GET['noredir'] ) )
</span><span class="cx">                 $noredir = true;
</span></span></pre></div>
<a id="trunkwpadmineditformcommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-comment.php (12112 => 12113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-comment.php        2009-10-27 00:23:58 UTC (rev 12112)
+++ trunk/wp-admin/edit-form-comment.php        2009-10-27 03:46:31 UTC (rev 12113)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">
</span><span class="cx"> <div id="major-publishing-actions">
</span><span class="cx"> <div id="delete-action">
</span><del>-<?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"; ?>
</del><ins>+<?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"; ?>
</ins><span class="cx"> </div>
</span><span class="cx"> <div id="publishing-action">
</span><span class="cx"> <input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />
</span></span></pre>
</div>
</div>
</body>
</html>