<!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, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { 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>[11741] trunk: "Trash" status for comments updates, props caesarsgrunt,
see #4529</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11741">11741</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2009-07-24 07:23:11 +0000 (Fri, 24 Jul 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>"Trash" status for comments updates, props caesarsgrunt, see <a href="http://trac.wordpress.org/ticket/4529">#4529</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditcommentsphp">trunk/wp-admin/edit-comments.php</a></li>
<li><a href="#trunkwpadminincludesdashboardphp">trunk/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpincludescommentphp">trunk/wp-includes/comment.php</a></li>
<li><a href="#trunkwpincludescronphp">trunk/wp-includes/cron.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
<li><a href="#trunkwpincludespluggablephp">trunk/wp-includes/pluggable.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-comments.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-comments.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-admin/edit-comments.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -250,16 +250,19 @@
</span><span class="cx"> <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
</span><span class="cx"> <option value="unapprove"><?php _e('Unapprove'); ?></option>
</span><span class="cx"> <?php endif; ?>
</span><del>-<?php if ( 'approved' != $comment_status ): ?>
</del><ins>+<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
</ins><span class="cx"> <option value="approve"><?php _e('Approve'); ?></option>
</span><span class="cx"> <?php endif; ?>
</span><del>-<?php if ( 'spam' != $comment_status ): ?>
</del><ins>+<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
</ins><span class="cx"> <option value="markspam"><?php _e('Mark as Spam'); ?></option>
</span><span class="cx"> <?php endif; ?>
</span><ins>+<?php if ( 'deleted' == $comment_status ): ?>
+<option value="unapprove"><?php _e('Return to Pending'); ?></option>
+<?php endif; ?>
</ins><span class="cx"> <?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
</span><span class="cx"> <option value="destroy"><?php _e('Delete Permanently'); ?></option>
</span><span class="cx"> <?php else: ?>
</span><del>-<option value="delete"><?php _e('Delete'); ?></option>
</del><ins>+<option value="delete"><?php _e('Move to Trash'); ?></option>
</ins><span class="cx"> <?php endif; ?>
</span><span class="cx"> </select>
</span><span class="cx"> <input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
</span><span class="lines">@@ -286,10 +289,12 @@
</span><span class="cx">         <input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
</span><span class="cx"> <?php }
</span><span class="cx">
</span><del>-if ( 'spam' == $comment_status || 'deleted' == $comment_status ) {
</del><ins>+if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) {
</ins><span class="cx">         wp_nonce_field('bulk-destroy', '_destroy_nonce');
</span><del>- if ( current_user_can ('moderate_comments')) { ?>
</del><ins>+ if ( 'spam' == $comment_status ) { ?>
</ins><span class="cx">                 <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
</span><ins>+<?php } elseif ( 'deleted' == $comment_status ) { ?>
+                <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-primary apply" />
</ins><span class="cx"> <?php }
</span><span class="cx"> } ?>
</span><span class="cx"> <?php do_action('manage_comments_nav', $comment_status); ?>
</span><span class="lines">@@ -341,22 +346,27 @@
</span><span class="cx"> <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
</span><span class="cx"> <option value="unapprove"><?php _e('Unapprove'); ?></option>
</span><span class="cx"> <?php endif; ?>
</span><del>-<?php if ( 'approved' != $comment_status ): ?>
</del><ins>+<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
</ins><span class="cx"> <option value="approve"><?php _e('Approve'); ?></option>
</span><span class="cx"> <?php endif; ?>
</span><del>-<?php if ( 'spam' != $comment_status ): ?>
</del><ins>+<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
</ins><span class="cx"> <option value="markspam"><?php _e('Mark as Spam'); ?></option>
</span><span class="cx"> <?php endif; ?>
</span><ins>+<?php if ( 'deleted' == $comment_status ): ?>
+<option value="unapprove"><?php _e('Return to Pending'); ?></option>
+<?php endif; ?>
</ins><span class="cx"> <?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
</span><span class="cx"> <option value="destroy"><?php _e('Delete Permanently'); ?></option>
</span><span class="cx"> <?php else: ?>
</span><del>-<option value="delete"><?php _e('Delete'); ?></option>
</del><ins>+<option value="delete"><?php _e('Move to Trash'); ?></option>
</ins><span class="cx"> <?php endif; ?>
</span><span class="cx"> </select>
</span><span class="cx"> <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
</span><span class="cx">
</span><del>-<?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?>
-<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
</del><ins>+<?php if ( 'spam' == $comment_status ) { ?>
+<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />
+<?php } elseif ( 'deleted' == $comment_status ) { ?>
+<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
</ins><span class="cx"> <?php } ?>
</span><span class="cx"> <?php do_action('manage_comments_nav', $comment_status); ?>
</span><span class="cx"> </div>
</span></span></pre></div>
<a id="trunkwpadminincludesdashboardphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/dashboard.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/dashboard.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-admin/includes/dashboard.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -539,10 +539,9 @@
</span><span class="cx">                 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
</span><span class="cx">                 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
</span><span class="cx">                 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
</span><del>-                //$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';
</del><span class="cx">                 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
</span><span class="cx">                 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
</span><del>-                $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
</del><ins>+                $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
</ins><span class="cx">
</span><span class="cx">                 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-admin/includes/template.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -2159,7 +2159,7 @@
</span><span class="cx">                                                         $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
</span><del>-                                                        $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
</del><ins>+                                                        $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
</ins><span class="cx">                                                 }
</span><span class="cx">
</span><span class="cx">                                                 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
</span></span></pre></div>
<a id="trunkwpincludescommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-includes/comment.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -743,7 +743,7 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx">         do_action('delete_comment', $comment_id);
</span><span class="cx">         
</span><del>-        wp_unschedule_comment_destruction($comment_id);
</del><ins>+        wp_unschedule_comment_delete($comment_id);
</ins><span class="cx">
</span><span class="cx">         $comment = get_comment($comment_id);
</span><span class="cx">
</span><span class="lines">@@ -1037,7 +1037,7 @@
</span><span class="cx"> */
</span><span class="cx"> function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
</span><span class="cx">         global $wpdb;
</span><del>-        wp_unschedule_comment_destruction($comment_id);
</del><ins>+        wp_unschedule_comment_delete($comment_id);
</ins><span class="cx">         
</span><span class="cx">         $status = '0';
</span><span class="cx">         switch ( $comment_status ) {
</span><span class="lines">@@ -1058,7 +1058,7 @@
</span><span class="cx">                         if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam')
</span><span class="cx">                                 return wp_delete_comment($comment_id);
</span><span class="cx">                         $status = 'deleted';
</span><del>-                        wp_schedule_comment_destruction($comment_id);
</del><ins>+                        wp_schedule_comment_delete($comment_id);
</ins><span class="cx">                         break;
</span><span class="cx">                 default:
</span><span class="cx">                         return false;
</span><span class="lines">@@ -1091,14 +1091,14 @@
</span><span class="cx"> * @param int $comment_id Comment ID.
</span><span class="cx"> * @return void
</span><span class="cx"> */
</span><del>-function wp_schedule_comment_destruction($comment_id) {
-        $to_destroy = get_option('to_destroy');
-        if (!is_array($to_destroy))
-                $to_destroy = array();
</del><ins>+function wp_schedule_comment_delete($comment_id) {
+        $to_delete = get_option('wp_scheduled_delete');
+        if ( !is_array($to_delete) )
+                $to_delete = array();
</ins><span class="cx">         
</span><del>-        $to_destroy['comments'][$comment_id] = time();
</del><ins>+        $to_delete['comments'][$comment_id] = time();
</ins><span class="cx">         
</span><del>-        update_option('to_destroy', $to_destroy);
</del><ins>+        update_option('wp_scheduled_delete', $to_delete);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1109,14 +1109,14 @@
</span><span class="cx"> * @param int $comment_id Comment ID.
</span><span class="cx"> * @return void
</span><span class="cx"> */
</span><del>-function wp_unschedule_comment_destruction($comment_id) {
-        $to_destroy = get_option('to_destroy');
-        if (!is_array($to_destroy))
</del><ins>+function wp_unschedule_comment_delete($comment_id) {
+        $to_delete = get_option('wp_scheduled_delete');
+        if ( !is_array($to_delete) )
</ins><span class="cx">                 return;
</span><span class="cx">         
</span><del>-        unset($to_destroy['comments'][$comment_id]);
</del><ins>+        unset($to_delete['comments'][$comment_id]);
</ins><span class="cx">         
</span><del>-        update_option('to_destroy', $to_destroy);
</del><ins>+        update_option('wp_scheduled_delete', $to_delete);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludescronphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/cron.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/cron.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-includes/cron.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -394,4 +394,6 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-?>
</del><ins>+add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
+if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
+        wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
</ins></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-includes/functions.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -3328,8 +3328,6 @@
</span><span class="cx">         return join( "\n", $structure );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
-
</del><span class="cx"> /**
</span><span class="cx"> * Strip close comment and close php tags from file headers used by WP
</span><span class="cx"> * See http://core.trac.wordpress.org/ticket/8497
</span><span class="lines">@@ -3339,4 +3337,32 @@
</span><span class="cx"> function _cleanup_header_comment($str) {
</span><span class="cx">         return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
</span><span class="cx"> }
</span><del>-?>
</del><ins>+
+/**
+ * Permanently deletes comments that have been scheduled for deleting.
+ * Will do the same for posts, pages, etc in the future.
+ *
+ * @access private
+ * @since 2.9.0
+ *
+ * @return void
+ */
+function wp_scheduled_delete() {
+        $to_delete = get_option('wp_scheduled_delete');
+        if (!is_array($to_delete))
+                return;
+
+        if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) )
+                $to_delete['comments'] = array();
+
+        $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);
+        $deletetimestamp = time() - $delete_delay;
+        foreach ($to_delete['comments'] as $comment_id => $timestamp) {
+                if ($timestamp < $deletetimestamp) {
+                        wp_delete_comment($comment_id);
+                        unset($to_delete['comments'][$comment_id]);
+                }
+        }
+
+        update_option('wp_scheduled_delete', $to_delete);
+}
</ins></span></pre></div>
<a id="trunkwpincludespluggablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pluggable.php (11740 => 11741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pluggable.php        2009-07-22 22:33:11 UTC (rev 11740)
+++ trunk/wp-includes/pluggable.php        2009-07-24 07:23:11 UTC (rev 11741)
</span><span class="lines">@@ -1767,32 +1767,3 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx">
</span><del>-/**
- * Destroys comments which have previously been scheduled for destruction.
- * Will do the same for posts, pages, etc in the future.
- *
- * @access private
- * @since 2.9.0
- *
- * @return void
- */
-function _scheduled_destruction() {
-        $to_destroy = get_option('to_destroy');
-        if (!is_array($to_destroy))
-                return;
-
-        $deletetimestamp = time()-(60*60*24*30);
-        foreach ($to_destroy['comments'] as $comment_id => $timestamp) {
-                if ($timestamp < $deletetimestamp) {
-                        wp_delete_comment($comment_id);
-                        unset($to_destroy['comments'][$comment_id]);
-                }
-        }
-
-        update_option('to_destroy', $to_destroy);
-}
-add_action( '_scheduled_destruction', '_scheduled_destruction' );
-if ( !wp_next_scheduled('_scheduled_destruction') && !defined('WP_INSTALLING') )
-        wp_schedule_event(time(), 'daily', '_scheduled_destruction');
-
-
</del></span></pre>
</div>
</div>
</body>
</html>