WordPress.org

Make WordPress Core

Changeset 12158


Ignore:
Timestamp:
11/09/09 20:12:07 (6 years ago)
Author:
ryan
Message:

Add force delete option.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r12156 r12158  
    11501150 * 
    11511151 * @param int $postid Post ID. 
     1152 * @param bool $force_delete Whether to bypass trash and force deletion 
    11521153 * @return mixed False on failure 
    11531154 */ 
    1154 function wp_delete_post($postid = 0) { 
     1155function wp_delete_post( $postid = 0, $force_delete = false ) { 
    11551156    global $wpdb, $wp_rewrite; 
    11561157 
     
    11581159        return $post; 
    11591160 
    1160     if ( ($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'trash' && EMPTY_TRASH_DAYS > 0 ) 
    1161         return wp_trash_post($postid); 
     1161    if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS > 0 ) 
     1162            return wp_trash_post($postid); 
    11621163 
    11631164    if ( $post->post_type == 'attachment' ) 
    1164         return wp_delete_attachment($postid); 
     1165        return wp_delete_attachment( $postid, $force_delete ); 
    11651166 
    11661167    do_action('delete_post', $postid); 
     
    28002801 * 
    28012802 * @param int $postid Attachment ID. 
     2803 * @param bool $force_delete Whether to bypass trash and force deletion 
    28022804 * @return mixed False on failure. Post data on success. 
    28032805 */ 
    2804 function wp_delete_attachment($post_id) { 
     2806function wp_delete_attachment( $post_id, $force_delete = false ) { 
    28052807    global $wpdb; 
    28062808 
     
    28112813        return false; 
    28122814 
    2813     if ( 'trash' != $post->post_status ) 
    2814         return wp_trash_post($post_id); 
     2815    if ( !$force_delete && 'trash' != $post->post_status ) 
     2816        return wp_trash_post( $post_id ); 
    28152817 
    28162818    delete_post_meta($post_id, '_wp_trash_meta_status'); 
Note: See TracChangeset for help on using the changeset viewer.