Make WordPress Core

Ticket #30940: 30940-2.patch

File 30940-2.patch, 2.8 KB (added by jadpm, 12 years ago)
  • post.php

     
    25812581function wp_delete_post( $postid = 0, $force_delete = false ) {
    25822582        global $wpdb;
    25832583
    2584         if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
    2585                 return $post;
     2584        if ( !$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
     2585                return $_post;
    25862586
    2587         if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
     2587        if ( !$force_delete && ( $_post->post_type == 'post' || $_post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
    25882588                        return wp_trash_post($postid);
    25892589
    2590         if ( $post->post_type == 'attachment' )
     2590        if ( $_post->post_type == 'attachment' )
    25912591                return wp_delete_attachment( $postid, $force_delete );
     2592       
     2593        $post = new WP_Post( $_post );
    25922594
    25932595        /**
    25942596         * Fires before a post is deleted, at the start of wp_delete_post().
    25952597         *
    25962598         * @since 3.2.0
     2599         * @since 4.2.0 Introduced the '$post' parameter.
    25972600         *
    25982601         * @see wp_delete_post()
    25992602         *
    2600          * @param int $postid Post ID.
     2603         * @param int    $postid Post ID.
     2604         * @param object $post   Post object.
    26012605         */
    2602         do_action( 'before_delete_post', $postid );
     2606        do_action( 'before_delete_post', $postid, $post );
    26032607
    26042608        delete_post_meta($postid,'_wp_trash_meta_status');
    26052609        delete_post_meta($postid,'_wp_trash_meta_time');
    … …  
    26382642         * Fires immediately before a post is deleted from the database.
    26392643         *
    26402644         * @since 1.2.0
     2645         * @since 4.2.0 Introduced the '$post' parameter.
    26412646         *
    2642          * @param int $postid Post ID.
     2647         * @param int    $postid Post ID.
     2648         * @param object $post   Post object.
    26432649         */
    2644         do_action( 'delete_post', $postid );
     2650        do_action( 'delete_post', $postid, $post );
    26452651        $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
    26462652        if ( ! $result ) {
    26472653                return false;
    … …  
    26512657         * Fires immediately after a post is deleted from the database.
    26522658         *
    26532659         * @since 2.2.0
     2660         * @since 4.2.0 Introduced the '$post' parameter.
    26542661         *
    2655          * @param int $postid Post ID.
     2662         * @param int    $postid Post ID.
     2663         * @param object $post   Post object.
    26562664         */
    2657         do_action( 'deleted_post', $postid );
     2665        do_action( 'deleted_post', $postid, $post );
    26582666
    26592667        clean_post_cache( $post );
    26602668
    … …  
    26692677         * Fires after a post is deleted, at the conclusion of wp_delete_post().
    26702678         *
    26712679         * @since 3.2.0
     2680         * @since 4.2.0 Introduced the '$post' parameter.
    26722681         *
    26732682         * @see wp_delete_post()
    26742683         *
    2675          * @param int $postid Post ID.
     2684         * @param int    $postid Post ID.
     2685         * @param object $post   Post object.
    26762686         */
    2677         do_action( 'after_delete_post', $postid );
     2687        do_action( 'after_delete_post', $postid, $post );
    26782688
    26792689        return $post;
    26802690}