Ticket #11470: trash-patch.diff

File trash-patch.diff, 2.6 KB (added by sirzooro, 3 years ago)

Force delete for action=delete links

Line 
1--- wp-admin/admin-ajax.php.ori 2009-12-19 11:32:36.156250000 +0100
2+++ wp-admin/admin-ajax.php     2009-12-20 20:48:47.921875000 +0100
3@@ -228,7 +228,7 @@
4                        die( (string) time() );
5                $r = wp_unspam_comment( $comment->comment_ID );
6        } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
7-               $r = wp_delete_comment( $comment->comment_ID );
8+               $r = wp_delete_comment( $comment->comment_ID, true );
9        } else {
10                die('-1');
11        }
12--- wp-admin/comment.php.ori    2009-12-19 11:32:36.187500000 +0100
13+++ wp-admin/comment.php        2009-12-20 20:38:31.265625000 +0100
14@@ -181,7 +181,7 @@
15 
16        switch ( $action ) {
17                case 'deletecomment' :
18-                       wp_delete_comment( $comment_id );
19+                       wp_delete_comment( $comment_id, true );
20                        $redir = add_query_arg( array('deleted' => '1'), $redir );
21                        break;
22                case 'trashcomment' :
23--- wp-admin/page.php.ori       2009-12-19 11:32:38.796875000 +0100
24+++ wp-admin/page.php   2009-12-20 20:38:06.421875000 +0100
25@@ -195,7 +195,7 @@
26                if ( ! wp_delete_attachment($page_id) )
27                        wp_die( __('Error in deleting...') );
28        } else {
29-               if ( !wp_delete_post($page_id) )
30+               if ( !wp_delete_post($page_id, true) )
31                        wp_die( __('Error in deleting...') );
32        }
33 
34--- wp-admin/post.php.ori       2009-12-19 11:32:38.828125000 +0100
35+++ wp-admin/post.php   2009-12-20 20:40:08.109375000 +0100
36@@ -231,13 +231,11 @@
37        if ( !current_user_can('delete_post', $post_id) )
38                wp_die( __('You are not allowed to delete this post.') );
39 
40-       $force = !EMPTY_TRASH_DAYS;
41        if ( $post->post_type == 'attachment' ) {
42-               $force = ( $force || !MEDIA_TRASH );
43-               if ( ! wp_delete_attachment($post_id, $force) )
44+               if ( ! wp_delete_attachment($post_id, true) )
45                        wp_die( __('Error in deleting...') );
46        } else {
47-               if ( !wp_delete_post($post_id, $force) )
48+               if ( !wp_delete_post($post_id, true) )
49                        wp_die( __('Error in deleting...') );
50        }
51 
52--- wp-includes/comment.php.ori 2009-12-19 11:32:39.875000000 +0100
53+++ wp-includes/comment.php     2009-12-20 20:46:21.734375000 +0100
54@@ -813,12 +813,12 @@
55  * @param int $comment_id Comment ID
56  * @return bool False if delete comment query failure, true on success.
57  */
58-function wp_delete_comment($comment_id) {
59+function wp_delete_comment($comment_id, $force_delete = false) {
60        global $wpdb;
61        if (!$comment = get_comment($comment_id))
62                return false;
63 
64-       if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0)
65+       if (!$force_delete && wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0)
66                return wp_trash_comment($comment_id);
67 
68        do_action('delete_comment', $comment_id);