PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.6
Forumax – AI Powered Advanced Community Forum Plugin v1.2.6
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_Forum.php

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

43 lines 1.3 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_Forum {
5 /**
6 * Create_Forum constructor.
7 */
8 public function __construct() {
9 add_action( 'admin_init', [ $this, 'bbp_create_forum' ] );
10 }
11
12 /**
13 * Create parent Doc post
14 */
15 public function bbp_create_forum() {
16 if ( ! empty ( $_GET['bbp_parent_title'] ) ) {
17 $bbp_parent_title = ! empty ( $_GET['bbp_parent_title'] ) ? sanitize_text_field( $_GET['bbp_parent_title'] ) : '';
18 $args = [
19 'post_type' => 'forum',
20 'post_parent' => 0
21 ];
22
23 $query = new \WP_Query( $args );
24 $total = $query->found_posts;
25 $add = 2;
26 $order = $total + $add;
27
28 // Create post object
29 $post = wp_insert_post( array(
30 'post_title' => $bbp_parent_title,
31 'post_parent' => 0,
32 'post_content' => '',
33 'post_type' => 'forum',
34 'post_status' => 'publish',
35 'post_author' => get_current_user_id(),
36 'menu_order' => $order,
37 ) );
38 wp_insert_post( $post, $wp_error = '' );
39 wp_safe_redirect( admin_url('admin.php?page=bbp-core') );
40 }
41 }
42 }
43 new Create_Forum();