Ticket #2059: 2059.diff
File 2059.diff, 1.4 KB (added by , 11 years ago) |
---|
-
includes/topics/functions.php
2933 2933 2934 2934 do_action( 'bbp_delete_topic', $topic_id ); 2935 2935 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, 2939 2943 'post_type' => bbp_get_reply_post_type(), 2940 'post_status' => 'any',2944 'post_status' => array_keys( get_post_stati() ), 2941 2945 'post_parent' => $topic_id, 2942 2946 'posts_per_page' => -1, 2943 2947 'nopaging' => true, 2944 'fields' => 'id=>parent' 2945 ) ) ) { 2948 'fields' => 'id=>parent' ) ); 2949 if ( empty( $replies->posts ) ) 2950 return true; 2951 2946 2952 foreach ( $replies->posts as $reply ) { 2947 2953 wp_delete_post( $reply->ID, true ); 2948 2954 } 2949 2955 2950 // Reset the $post global2951 2956 wp_reset_postdata(); 2957 2958 return true; 2959 2952 2960 } 2953 }2954 2961 2955 2962 /** 2956 2963 * Called before trashing a topic