WordPress.org

Make WordPress Core

Ticket #10647: post.patch

File post.patch, 1.6 KB (added by scribu, 9 years ago)
  • wp-includes/post.php

     
    11351135 * @param int $postid Post ID.
    11361136 * @return mixed False on failure
    11371137 */
    1138 function wp_delete_post($postid = 0) {
     1138function wp_delete_post($postid = 0, $force = false) {
    11391139        global $wpdb, $wp_rewrite;
    11401140
    1141         if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
     1141        if ( !$post = wp_get_single_post($postid) )
    11421142                return $post;
    11431143
    1144         if ( ($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'trash' && EMPTY_TRASH_DAYS > 0 )
     1144        if ( !$force && ($post->post_type == 'post' || $post->post_type == 'page') && $post->post_status != 'trash' && EMPTY_TRASH_DAYS > 0 )
    11451145                return wp_trash_post($postid);
    1146                
     1146
    11471147        if ( $post->post_type == 'attachment' )
    11481148                return wp_delete_attachment($postid);
    11491149
     
    26542654 * @param int $postid Attachment ID.
    26552655 * @return mixed False on failure. Post data on success.
    26562656 */
    2657 function wp_delete_attachment($postid) {
     2657function wp_delete_attachment($postid, $force = false) {
    26582658        global $wpdb;
    26592659
    2660         if ( !$post = $wpdb->get_row(  $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
     2660        if ( !$post = wp_get_single_post($postid) )
    26612661                return $post;
    26622662
    26632663        if ( 'attachment' != $post->post_type )
    26642664                return false;
    26652665
    2666         if ( 'trash' != $post->post_status )
     2666        if ( !$force && 'trash' != $post->post_status )
    26672667                return wp_trash_post($postid);
    26682668
    26692669        $trash_meta = get_option('wp_trash_meta');