<!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>[13995] trunk/wp-includes: Add $force_delete to wp_delete_comment().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13995">13995</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-04 12:20:19 +0000 (Sun, 04 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add $force_delete to wp_delete_comment(). see <a href="http://trac.wordpress.org/ticket/12766">#12766</a>, see <a href="http://trac.wordpress.org/ticket/11470">#11470</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescommentphp">trunk/wp-includes/comment.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment.php (13994 => 13995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment.php        2010-04-04 12:07:27 UTC (rev 13994)
+++ trunk/wp-includes/comment.php        2010-04-04 12:20:19 UTC (rev 13995)
</span><span class="lines">@@ -856,8 +856,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Removes comment ID and maybe updates post comment count.
</del><ins>+ * Trashes or deletes a comment.
</ins><span class="cx">  *
</span><ins>+ * The comment is moved to trash instead of permanently deleted unless trash is
+ * disabled, item is already in the trash, or $force_delete is true.
+ *
</ins><span class="cx">  * The post comment count will be updated if the comment was approved and has a
</span><span class="cx">  * post ID available.
</span><span class="cx">  *
</span><span class="lines">@@ -869,14 +872,15 @@
</span><span class="cx">  * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
</span><span class="cx">  *
</span><span class="cx">  * @param int $comment_id Comment ID
</span><ins>+ * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
</ins><span class="cx">  * @return bool False if delete comment query failure, true on success.
</span><span class="cx">  */
</span><del>-function wp_delete_comment($comment_id) {
</del><ins>+function wp_delete_comment($comment_id, $force_delete = false) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">         if (!$comment = get_comment($comment_id))
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        if (wp_get_comment_status($comment_id) != 'trash' &amp;&amp; wp_get_comment_status($comment_id) != 'spam' &amp;&amp; EMPTY_TRASH_DAYS &gt; 0)
</del><ins>+        if ( !$force_delete &amp;&amp; EMPTY_TRASH_DAYS &amp;&amp; !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) )
</ins><span class="cx">                 return wp_trash_comment($comment_id);
</span><span class="cx"> 
</span><span class="cx">         do_action('delete_comment', $comment_id);
</span><span class="lines">@@ -915,16 +919,19 @@
</span><span class="cx"> /**
</span><span class="cx">  * Moves a comment to the Trash
</span><span class="cx">  *
</span><ins>+ * If trash is disabled, comment is permanently deleted.
+ *
</ins><span class="cx">  * @since 2.9.0
</span><span class="cx">  * @uses do_action() on 'trash_comment' before trashing
</span><span class="cx">  * @uses do_action() on 'trashed_comment' after trashing
</span><ins>+ * @uses wp_delete_comment() if trash is disabled
</ins><span class="cx">  *
</span><span class="cx">  * @param int $comment_id Comment ID.
</span><span class="cx">  * @return mixed False on failure
</span><span class="cx">  */
</span><span class="cx"> function wp_trash_comment($comment_id) {
</span><del>-        if ( EMPTY_TRASH_DAYS == 0 )
-                return wp_delete_comment($comment_id);
</del><ins>+        if ( !EMPTY_TRASH_DAYS )
+                return wp_delete_comment($comment_id, true);
</ins><span class="cx"> 
</span><span class="cx">         if ( !$comment = get_comment($comment_id) )
</span><span class="cx">                 return false;
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (13994 => 13995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-04-04 12:07:27 UTC (rev 13994)
+++ trunk/wp-includes/post.php        2010-04-04 12:20:19 UTC (rev 13995)
</span><span class="lines">@@ -1592,18 +1592,22 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Removes a post, attachment, or page.
</del><ins>+ * Trashes or deletes a post or page.
</ins><span class="cx">  *
</span><del>- * When the post and page goes, everything that is tied to it is deleted also.
</del><ins>+ * When the post and page is permanently deleted, everything that is tied to it is deleted also.
</ins><span class="cx">  * This includes comments, post meta fields, and terms associated with the post.
</span><span class="cx">  *
</span><ins>+ * The post or page is moved to trash instead of permanently deleted unless trash is
+ * disabled, item is already in the trash, or $force_delete is true.
+ *
</ins><span class="cx">  * @since 1.0.0
</span><span class="cx">  * @uses do_action() on 'delete_post' before deletion unless post type is 'attachment'.
</span><span class="cx">  * @uses do_action() on 'deleted_post' after deletion unless post type is 'attachment'.
</span><span class="cx">  * @uses wp_delete_attachment() if post type is 'attachment'.
</span><ins>+ * @uses wp_trash_post() if item should be trashed.
</ins><span class="cx">  *
</span><span class="cx">  * @param int $postid Post ID.
</span><del>- * @param bool $force_delete Whether to bypass trash and force deletion
</del><ins>+ * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false.
</ins><span class="cx">  * @return mixed False on failure
</span><span class="cx">  */
</span><span class="cx"> function wp_delete_post( $postid = 0, $force_delete = false ) {
</span><span class="lines">@@ -1612,7 +1616,7 @@
</span><span class="cx">         if ( !$post = $wpdb-&gt;get_row($wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;posts WHERE ID = %d&quot;, $postid)) )
</span><span class="cx">                 return $post;
</span><span class="cx"> 
</span><del>-        if ( !$force_delete &amp;&amp; ( $post-&gt;post_type == 'post' || $post-&gt;post_type == 'page') &amp;&amp; get_post_status( $postid ) != 'trash' &amp;&amp; EMPTY_TRASH_DAYS &gt; 0 )
</del><ins>+        if ( !$force_delete &amp;&amp; ( $post-&gt;post_type == 'post' || $post-&gt;post_type == 'page') &amp;&amp; get_post_status( $postid ) != 'trash' &amp;&amp; EMPTY_TRASH_DAYS )
</ins><span class="cx">                         return wp_trash_post($postid);
</span><span class="cx"> 
</span><span class="cx">         if ( $post-&gt;post_type == 'attachment' )
</span><span class="lines">@@ -1698,16 +1702,19 @@
</span><span class="cx"> /**
</span><span class="cx">  * Moves a post or page to the Trash
</span><span class="cx">  *
</span><ins>+ * If trash is disabled, the post or page is permanently deleted.
+ *
</ins><span class="cx">  * @since 2.9.0
</span><span class="cx">  * @uses do_action() on 'trash_post' before trashing
</span><span class="cx">  * @uses do_action() on 'trashed_post' after trashing
</span><ins>+ * @uses wp_delete_post() if trash is disabled
</ins><span class="cx">  *
</span><span class="cx">  * @param int $postid Post ID.
</span><span class="cx">  * @return mixed False on failure
</span><span class="cx">  */
</span><span class="cx"> function wp_trash_post($post_id = 0) {
</span><del>-        if ( EMPTY_TRASH_DAYS == 0 )
-                return wp_delete_post($post_id);
</del><ins>+        if ( !EMPTY_TRASH_DAYS )
+                return wp_delete_post($post_id, true);
</ins><span class="cx"> 
</span><span class="cx">         if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
</span><span class="cx">                 return $post;
</span><span class="lines">@@ -3296,18 +3303,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Delete an attachment.
</del><ins>+ * Trashes or deletes an attachment.
</ins><span class="cx">  *
</span><del>- * Will remove the file also, when the attachment is removed. Removes all post
- * meta fields, taxonomy, comments, etc associated with the attachment (except
- * the main post).
</del><ins>+ * When an attachment is permanently deleted, the file will also be removed.
+ * Deletion removes all post meta fields, taxonomy, comments, etc. associated
+ * with the attachment (except the main post).
</ins><span class="cx">  *
</span><ins>+ * The attachment is moved to the trash instead of permanently deleted unless trash
+ * for media is disabled, item is already in the trash, or $force_delete is true.
+ *
</ins><span class="cx">  * @since 2.0.0
</span><span class="cx">  * @uses $wpdb
</span><span class="cx">  * @uses do_action() Calls 'delete_attachment' hook on Attachment ID.
</span><span class="cx">  *
</span><span class="cx">  * @param int $postid Attachment ID.
</span><del>- * @param bool $force_delete Whether to bypass trash and force deletion
</del><ins>+ * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false.
</ins><span class="cx">  * @return mixed False on failure. Post data on success.
</span><span class="cx">  */
</span><span class="cx"> function wp_delete_attachment( $post_id, $force_delete = false ) {
</span></span></pre>
</div>
</div>

</body>
</html>