PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.4
Forumax – AI Powered Advanced Community Forum Plugin v1.2.4
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 / Create_Topic.php

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

45 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Admin;
3
4 class Create_Topic {
5 /**
6 * Create_Forum constructor.
7 */
8 public function __construct() {
9 add_action( 'admin_init', [ $this, 'bbp_create_topic' ] );
10 }
11
12 /**
13 * Create parent Doc post
14 */
15 public function bbp_create_topic() {
16
17 if ( isset ( $_GET['is_bbp_section'] ) && ! empty ( $_GET['is_bbp_section'] ) ) {
18
19 $parentID = ! empty ( $_GET['bbp_parentID'] ) ? absint( $_GET['bbp_parentID'] ) : 0;
20 $section_title = ! empty ( $_GET['is_bbp_section'] ) ? sanitize_text_field( $_GET['is_bbp_section'] ) : '';
21 $parent_item = get_children( array(
22 'post_parent' => $parentID,
23 'post_type' => 'topic'
24 ) );
25
26 $add = 2;
27 $order = count( $parent_item );
28 $order = $order + $add;
29
30 // Create post object
31 $post = array(
32 'post_title' => $section_title,
33 'post_parent' => $parentID,
34 'post_content' => '',
35 'post_type' => 'topic',
36 'post_status' => 'publish',
37 'menu_order' => $order
38 );
39 wp_insert_post( $post, $wp_error = '' );
40 wp_safe_redirect( admin_url('admin.php?page=bbp-core') );
41 }
42
43 }
44 }
45 new Create_Topic();