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/admin_ui/topics.php +25 -45 1.4.1 → 2.5.1 View file →
@@ -3,27 +3,21 @@
3 3 while ( $children->have_posts() ) :
4 4 $children->the_post();
5 5 $current_topic_id = get_the_ID();
6 6
7 - $replies = new WP_Query(
8 - [
9 - 'post_parent' => $current_topic_id,
10 - 'post_type' => bbp_get_reply_post_type(),
11 - 'post_status' => [ 'publish', 'draft', 'pending' ],
12 - ]
13 - );
7 + // Batched in admin_ui.php via forumax_admin_reply_stats().
8 + $total_replies = (int) ( $reply_stats['total'][ $current_topic_id ] ?? 0 );
9 + $pending_replies = $reply_stats['pending'][ $current_topic_id ] ?? [];
14 10
15 - $pending_replies = [];
16 -
17 - $no_reply = 0 == $replies->found_posts ? 'no-reply' : '';
18 - $is_solved = isset($GLOBALS['bbp_solved_topic']) && $GLOBALS['bbp_solved_topic']->is_solved( $current_topic_id ) ? ' solved' : ' unsolved';
11 + $no_reply = 0 === $total_replies ? 'no-reply' : '';
12 + $is_solved = isset($GLOBALS['forumax_solve_topic']) && $GLOBALS['forumax_solve_topic']->is_solved( $current_topic_id ) ? ' solved' : ' unsolved';
19 13 $is_open = bbp_is_topic_closed( $current_topic_id ) ? ' closed-topics' : ' open-topics';
20 14 $is_hidden = bbp_is_topic_spam( $current_topic_id ) || bbp_is_topic_pending( $current_topic_id ) ? ' hidden-topics' : '';
21 15 $approve_btn = '';
22 16
23 17 if ( bbp_is_topic_spam( $current_topic_id ) ) {
24 - $url = admin_url( 'admin.php' ) . '/Approve_Topic.php?bbpc_approve_topic_id=' . $current_topic_id;
25 - $approve_btn = sprintf( '<a class="bbpc-approve-btn" href=%1$s><span class="dashicons dashicons-yes" title="%2$s"></span></a>', $url, __( 'Approve this topic', 'bbp-core' ) );
18 + $url = wp_nonce_url( admin_url( 'admin.php?bbpc_approve_topic_id=' . $current_topic_id ), 'bbpc_approve_topic_' . $current_topic_id );
19 + $approve_btn = sprintf( '<a class="bbpc-approve-btn" href="%1$s"><span class="dashicons dashicons-yes" title="%2$s"></span></a>', esc_url( $url ), esc_attr__( 'Approve this Topic', 'forumax' ) );
26 20 }
27 21
28 22 $filter_class = $no_reply . $is_solved . $is_open . $is_hidden;
29 23
@@ -43,14 +37,14 @@
43 37 <span class="topic-status">
44 38 <?php
45 39 // Return the Topic status icon Open, Close, Hidden (spam & pending) and which topic has No reply, is Resolved, is Unresolved.
46 40 if ( bbp_is_topic_closed( $current_topic_id ) ) {
47 - echo '<span class="dashicons dashicons-dismiss" title="'.esc_attr__('Status: Closed.', 'bbp-core').'"></span>';
41 + echo '<span class="dashicons dashicons-dismiss" title="'.esc_attr__('Status: Closed.', 'forumax').'"></span>';
48 42 } elseif ( bbp_is_topic_spam( $current_topic_id ) || bbp_is_topic_pending( $current_topic_id ) ) {
49 43 $hidden_status = bbp_is_topic_spam( $current_topic_id ) ? 'Spam ' : 'Pending ';
50 - echo '<span class="dashicons dashicons-hidden" title="' . esc_attr( $hidden_status . __( 'Status: Topic', 'bbp-core' ) ) . '"></span>';
44 + echo '<span class="dashicons dashicons-hidden" title="' . esc_attr( $hidden_status . __( 'Status: Topic', 'forumax' ) ) . '"></span>';
51 45 } elseif ( bbp_is_topic_open( $current_topic_id ) ) {
52 - ?> <img src="<?php echo esc_url( BBPC_IMG . 'icon/open.svg' ); ?>" alt="<?php esc_attr_e( 'Open icon', 'bbp-core' ) ?>" title="<?php echo esc_attr__( 'Open Topic', 'bbp-core' ) ?>"> <?php
46 + ?> <img src="<?php echo esc_url( FORUMAX_IMG . 'icon/open.svg' ); ?>" alt="<?php esc_attr_e( 'Open icon', 'forumax' ) ?>" title="<?php echo esc_attr__( 'Open Topic', 'forumax' ) ?>"> <?php
53 47 } else {
54 48 echo '<span class="dashicons dashicons-info-outline"></span>';
55 49 }
56 50 ?>
@@ -56,20 +50,20 @@
56 50 ?>
57 51 </span>
58 52 <h4>
59 53 <a href="<?php echo esc_attr( $edit_link ); ?>" target="<?php echo esc_attr( $target ); ?>">
60 - <?php the_title(); ?>
54 + <?php echo esc_html( get_the_title( $current_topic_id ) ); ?>
61 55 </a>
62 56 </h4>
63 57 <!-- Topic Author -->
64 58 <span class="bbpc-author-name">
65 59 <?php
66 - esc_html_e( '&nbsp; By: ', 'bbp-core' );
60 + esc_html_e( '&nbsp; By: ', 'forumax' );
67 61
68 62 echo wp_kses_post(
69 63 bbp_get_topic_author_link(
70 64 array(
71 - 'post_id' => get_the_ID(),
65 + 'post_id' => $current_topic_id,
72 66 'type' => 'name',
73 67 )
74 68 )
75 69 );
@@ -90,26 +84,15 @@
90 84 ];
91 85
92 86 echo wp_kses( $approve_btn, $allowed_html );
93 87
94 - while ( $replies->have_posts() ) :
95 - $replies->the_post();
96 - $reply_id = get_the_ID();
97 -
98 - if ( bbp_is_reply_pending( $reply_id ) ) {
99 - $pending_replies[] = $reply_id;
100 - }
101 -
102 - endwhile;
103 - wp_reset_postdata();
104 -
105 88 $pending_replies_count = count( $pending_replies );
106 - $reply_count = $replies->found_posts - $pending_replies_count;
89 + $reply_count = $total_replies - $pending_replies_count;
107 90 ?>
108 91 <div
109 92 title="<?php echo esc_attr( sprintf(
110 93 /* translators: %d: Number of published replies */
111 - __( '%d Published replies', 'bbp-core' ),
94 + __( '%d Published replies', 'forumax' ),
112 95 $reply_count
113 96 ) ); ?>">
114 97
115 98 <span class="bbpc-reply-count bbpc-published-replies">
@@ -122,9 +105,9 @@
122 105 ?>
123 106 <div click-target='<?php echo esc_attr( $current_topic_id ); ?>'
124 107 title="<?php echo esc_attr( sprintf(
125 108 /* translators: %d: Number of Pending replies */
126 - __( '%d Pending replies', 'bbp-core' ),
109 + __( '%d Pending replies', 'forumax' ),
127 110 $pending_replies_count
128 111 ) ); ?>">
129 112 <span class="bbpc-reply-count bbpc-pending-replies">
130 113 <?php echo esc_html( $pending_replies_count ); ?>
@@ -135,9 +118,9 @@
135 118 ?>
136 119
137 120 <ul class="actions">
138 121 <li>
139 - <a href="<?php echo esc_url( get_permalink( $current_topic_id ) ); ?>" target="_blank" title="<?php esc_attr_e( 'View this reply in new tab', 'bbp-core' ); ?>">
122 + <a href="<?php echo esc_url( get_permalink( $current_topic_id ) ); ?>" target="_blank" title="<?php esc_attr_e( 'View this reply in new tab', 'forumax' ); ?>">
140 123 <span class="dashicons dashicons-external"></span>
141 124 </a>
142 125 </li>
143 126
@@ -142,9 +125,9 @@
142 125 </li>
143 126
144 127 <?php if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) : ?>
145 128 <li class="delete">
146 - <a href="javascript:void(0)" bbp_topic_ID="<?php the_ID(); ?>" class="section-delete" title="<?php esc_attr_e( 'Move this topic to the Trash', 'bbp-core' ); ?>">
129 + <a href="javascript:void(0)" bbp_topic_ID="<?php echo esc_attr( $current_topic_id ); ?>" class="section-delete" title="<?php esc_attr_e( 'Move this topic to the Trash', 'forumax' ); ?>">
147 130 <span class="dashicons dashicons-trash"></span>
148 131 </a>
149 132 </li>
150 133 <?php endif; ?>
@@ -152,9 +135,9 @@
152 135 </div>
153 136 <div class="right-content">
154 137 <!-- Topic Refresh Time -->
155 138 <span class="progress-text">
156 - <?php bbp_topic_freshness_link() ?>
139 + <?php bbp_topic_freshness_link( $current_topic_id ); ?>
157 140 </span>
158 141 <!-- ./Topic Refresh Time -->
159 142 </div>
160 143 </div>
@@ -163,21 +146,20 @@
163 146 <?php if ( ! empty( $pending_replies_count ) ) : ?>
164 147 <ul class="bbpc-nested-replies" reply-target=<?php echo esc_attr( $current_topic_id ); ?>>
165 148 <?php
166 149 foreach ( $pending_replies as $p_reply ) {
167 - setup_postdata( $p_reply );
168 150 ?>
169 - <li reply-id="<?php the_ID(); ?>" class="bbpc-reply-wrap">
151 + <li reply-id="<?php echo esc_attr( $p_reply ); ?>" class="bbpc-reply-wrap">
170 152 <?php
171 - echo esc_html( wp_trim_words( get_the_content(), 10, '...' ) );
153 + echo esc_html( wp_trim_words( get_post_field( 'post_content', $p_reply ), 10, '...' ) );
172 154 echo ' - ';
173 - the_author();
155 + echo esc_html( bbp_get_reply_author_display_name( $p_reply ) );
174 156 ?>
175 157 <?php
176 158 if ( bbp_is_reply_pending( $p_reply ) ) {
177 - $url = admin_url( 'admin.php' ) . '/Approve_Topic.php?bbpc_approve_reply_id=' . $p_reply;
178 - $approve_btn = sprintf( '<a class="bbpc-approve-btn" href=%1$s><span class="dashicons dashicons-yes" title="%2$s"></span></a>', $url, __( 'Approve this topic', 'bbp-core' ) );
179 - }
159 + $url = wp_nonce_url( admin_url( 'admin.php?bbpc_approve_reply_id=' . $p_reply ), 'bbpc_approve_reply_' . $p_reply );
160 + $approve_btn = sprintf( '<a class="bbpc-approve-btn" href="%1$s"><span class="dashicons dashicons-yes" title="%2$s"></span></a>', esc_url( $url ), esc_attr__( 'Approve This Reply', 'forumax' ) );
161 + }
180 162
181 163 $allowed_html = [
182 164 'a' => [
183 165 'href' => [],
@@ -194,10 +176,8 @@
194 176 ?>
195 177 </li>
196 178 <?php
197 179 }
198 -
199 - wp_reset_postdata();
200 180 ?>
201 181 </ul>
202 182 <?php endif; ?>
203 183 </div>