PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.1
Forumax – AI Powered Advanced Community Forum Plugin v2.5.1
2.5.1 2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 All 31 releases
← All changes | includes/admin/menu/Delete_Topic.php +5 -20 2.4.4 → 2.5.1 View file →
@@ -26,30 +26,15 @@
26 26 if ( empty( $topic_id ) ) {
27 27 wp_send_json_error( 'Topic ID cannot be empty.' );
28 28 }
29 29
30 - $replies = get_children( [
31 - 'post_parent' => $topic_id,
32 - 'post_type' => 'reply',
33 - 'orderby' => 'menu_order',
34 - 'order' => 'asc',
35 - ] );
36 -
37 - $reply_ids = '';
38 - if ( is_array( $replies ) ) {
39 - foreach ( $replies as $reply ) {
40 - $reply_ids .= $reply->ID . ',';
41 - }
30 + if ( ! bbp_is_topic( $topic_id ) ) {
31 + wp_send_json_error( 'Invalid topic.' );
42 32 }
43 33
44 - $topic_posts = $topic_id . ',' . $reply_ids;
45 - $topic_posts = explode( ',', $topic_posts );
46 - $topic_posts_int = array_map( 'intval', $topic_posts );
47 -
48 - foreach ( $topic_posts_int as $delete_topic ) {
49 - if ( ! empty( $delete_topic ) ) {
50 - wp_trash_post( $delete_topic );
51 - }
34 + // bbPress trashes the topic's replies on wp_trash_post and restores them on untrash.
35 + if ( ! wp_trash_post( $topic_id ) ) {
36 + wp_send_json_error( 'Failed to delete the topic.' );
52 37 }
53 38
54 39 wp_send_json_success( 'Topic Deleted successfully.' );
55 40 wp_die();