Skip to:
Content

bbPress.org

Ticket #2059: 2059.2.diff

File 2059.2.diff, 1.4 KB (added by MZAWeb, 9 years ago)
  • includes/topics/functions.php

     
    29332933
    29342934        do_action( 'bbp_delete_topic', $topic_id );
    29352935
    2936         // Topic is being permanently deleted, so its replies gotta go too
    2937         if ( $replies = new WP_Query( array(
    2938                 'suppress_filters' => true,
     2936        /*
     2937        * Topic is being permanently deleted, so its replies gotta go too.
     2938        * We want to delte _all_ replies, regardles of it's stati, and WP_Query's
     2939        * post_status=>any only gets posts which status is not marked as 'exclude_from_search'
     2940        * so posts in the trash, for example, were not beign deleted.
     2941        */
     2942        $replies = new WP_Query( array( 'suppress_filters' => true,
    29392943                'post_type'        => bbp_get_reply_post_type(),
    2940                 'post_status'      => 'any',
     2944                'post_status'      => array_keys( get_post_stati() ),
    29412945                'post_parent'      => $topic_id,
    29422946                'posts_per_page'   => -1,
    29432947                'nopaging'         => true,
    2944                 'fields'           => 'id=>parent'
    2945         ) ) ) {
     2948                                        'fields'           => 'id=>parent' ) );
     2949        if ( empty( $replies->posts ) )
     2950                return true;
     2951
    29462952                foreach ( $replies->posts as $reply ) {
    29472953                        wp_delete_post( $reply->ID, true );
    29482954                }
    29492955
    2950                 // Reset the $post global
    29512956                wp_reset_postdata();
     2957
     2958        return true;
     2959
    29522960        }
    2953 }
    29542961
    29552962/**
    29562963 * Called before trashing a topic