WordPress.org

Make WordPress Core

Ticket #11470: trash-patch.diff

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

Force delete for action=delete links

  • wp-admin/admin-ajax.php

    old new  
    228228                        die( (string) time() ); 
    229229                $r = wp_unspam_comment( $comment->comment_ID ); 
    230230        } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { 
    231                 $r = wp_delete_comment( $comment->comment_ID ); 
     231                $r = wp_delete_comment( $comment->comment_ID, true ); 
    232232        } else { 
    233233                die('-1'); 
    234234        } 
  • wp-admin/comment.php

    old new  
    181181 
    182182        switch ( $action ) { 
    183183                case 'deletecomment' : 
    184                         wp_delete_comment( $comment_id ); 
     184                        wp_delete_comment( $comment_id, true ); 
    185185                        $redir = add_query_arg( array('deleted' => '1'), $redir ); 
    186186                        break; 
    187187                case 'trashcomment' : 
  • wp-admin/page.php

    old new  
    195195                if ( ! wp_delete_attachment($page_id) ) 
    196196                        wp_die( __('Error in deleting...') ); 
    197197        } else { 
    198                 if ( !wp_delete_post($page_id) ) 
     198                if ( !wp_delete_post($page_id, true) ) 
    199199                        wp_die( __('Error in deleting...') ); 
    200200        } 
    201201 
  • wp-admin/post.php

    old new  
    231231        if ( !current_user_can('delete_post', $post_id) ) 
    232232                wp_die( __('You are not allowed to delete this post.') ); 
    233233 
    234         $force = !EMPTY_TRASH_DAYS; 
    235234        if ( $post->post_type == 'attachment' ) { 
    236                 $force = ( $force || !MEDIA_TRASH ); 
    237                 if ( ! wp_delete_attachment($post_id, $force) ) 
     235                if ( ! wp_delete_attachment($post_id, true) ) 
    238236                        wp_die( __('Error in deleting...') ); 
    239237        } else { 
    240                 if ( !wp_delete_post($post_id, $force) ) 
     238                if ( !wp_delete_post($post_id, true) ) 
    241239                        wp_die( __('Error in deleting...') ); 
    242240        } 
    243241 
  • wp-includes/comment.php

    old new  
    813813 * @param int $comment_id Comment ID 
    814814 * @return bool False if delete comment query failure, true on success. 
    815815 */ 
    816 function wp_delete_comment($comment_id) { 
     816function wp_delete_comment($comment_id, $force_delete = false) { 
    817817        global $wpdb; 
    818818        if (!$comment = get_comment($comment_id)) 
    819819                return false; 
    820820 
    821         if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0) 
     821        if (!$force_delete && wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0) 
    822822                return wp_trash_comment($comment_id); 
    823823 
    824824        do_action('delete_comment', $comment_id);