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/Create_Topic.php +14 -5 2.5.0 → 2.5.1 View file →
@@ -29,16 +29,25 @@
29 29
30 30 $forum_id = ! empty( $_POST['forum_id'] ) ? absint( $_POST['forum_id'] ) : 0;
31 31 $topic_author = bbp_get_current_user_id();
32 32
33 - $parent_item = get_children( [
34 - 'post_parent' => $forum_id,
35 - 'post_type' => 'topic',
33 + if ( ! bbp_is_forum( $forum_id ) ) {
34 + wp_send_json_error( 'Invalid forum.' );
35 + }
36 +
37 + // Only the count is needed.
38 + $parent_items = new WP_Query( [
39 + 'post_parent' => $forum_id,
40 + 'post_type' => 'topic',
41 + 'post_status' => 'any',
42 + 'posts_per_page' => 1,
43 + 'fields' => 'ids',
44 + 'update_post_meta_cache' => false,
45 + 'update_post_term_cache' => false,
36 46 ] );
37 47
38 48 $add = 2;
39 - $order = count( $parent_item );
40 - $order = $order + $add;
49 + $order = (int) $parent_items->found_posts + $add;
41 50
42 51 // Create topic object
43 52 $topic_data = apply_filters( 'bbp_new_topic_pre_insert', [
44 53 'post_author' => $topic_author,