PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.3
Forumax – AI Powered Advanced Community Forum Plugin v1.2.3
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_Topic.php

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

50 lines 1.1 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_Topic {
9
10 /**
11 * Create_Post constructor.
12 */
13 public function __construct() {
14 add_action( 'admin_init', [ $this, 'delete_topic' ] );
15 }
16
17 /**
18 * Delete Parent Doc
19 */
20 public function delete_topic() {
21
22 if ( ! empty ( $_GET['topic_ID'] ) ) {
23 $topic_id = $_GET['topic_ID'] ?? '';
24 $topics = get_children(
25 [
26 'post_parent' => $_GET['topic_ID'],
27 'post_type' => 'reply',
28 'orderby' => 'menu_order',
29 'order' => 'asc',
30 ]
31 );
32
33 $forum_topics = '';
34 if ( is_array( $topics ) ) :
35 foreach ( $topics as $topic ) :
36 $forum_topics .= $topic->ID . ',';
37 endforeach;
38 endif;
39
40 $topics_id = $topic_id . ',' . $forum_topics;
41 $topic_ids = explode( ',', $topics_id );
42 $topic_id_int = array_map( 'intval', $topic_ids );
43 foreach ( $topic_id_int as $delete_topic ) {
44 wp_trash_post( $delete_topic, true );
45 }
46 wp_safe_redirect(admin_url( 'admin.php?page=bbp-core' ));
47 }
48 }
49 }
50 new Delete_Topic();