PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.2
Forumax – AI Powered Advanced Community Forum Plugin v1.2.2
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 2.0.0 2.1.0 All 29 releases
bbp-core / includes / admin / menu / Delete_Forum.php

Delete_Forum.php in Forumax – AI Powered Advanced Community Forum Plugin 1.2.2, at includes/admin/menu/Delete_Forum.php

65 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace admin\menu;
3
4 /**
5 * Class Delete_Post
6 * @package BBP-core\Admin\Menu
7 */
8 class Delete_Forum {
9
10 /**
11 * Create_Post constructor.
12 */
13 public function __construct() {
14 add_action( 'admin_init', [ $this, 'delete_forum' ] );
15 }
16
17 /**
18 * Delete Parent Doc
19 */
20 public function delete_forum() {
21 if ( ! empty( $_GET['forum_ID'] ) ) {
22 $parent_forum_id = $_GET['forum_ID'] ?? '';
23 $children = get_children(
24 [
25 'post_parent' => $_GET['forum_ID'],
26 'post_type' => 'topic',
27 'orderby' => 'menu_order',
28 'order' => 'asc',
29 ]
30 );
31
32 $topics = '';
33 $topic_replies = '';
34 if ( is_array( $children ) ) :
35 foreach ( $children as $child ) :
36 $replies = get_children(
37 [
38 'post_parent' => $child->ID,
39 'post_type' => 'reply',
40 'post_status' => [ 'publish', 'draft' ],
41 ]
42 );
43
44 $topics .= $child->ID . ',';
45 if ( is_array( $replies ) ) :
46 foreach ( $replies as $reply ) :
47 $topic_replies .= $reply->ID . ',';
48 endforeach;
49 endif;
50
51 endforeach;
52 endif;
53
54 $forum_ids = $parent_forum_id . ',' . $topic_replies . $topics;
55 $forum_id = explode( ',', $forum_ids );
56 $forum_id_int = array_map( 'intval', $forum_id );
57 foreach ( $forum_id_int as $deletes ) {
58 wp_trash_post( $deletes, true );
59 }
60 wp_safe_redirect( admin_url( 'admin.php?page=bbp-core' ) );
61 }
62 }
63 }
64 new Delete_Forum();
65