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 +97 -62 1.2.9 → 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 - $is_hidden = bbp_is_topic_spam( $current_topic_id ) ? ' hidden-topics' : '';
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
@@ -32,8 +26,9 @@
32 26 <div class="accordion-title ez-section-title">
33 27 <?php
34 28 $edit_link = 'javascript:void( 0 )';
35 29 $target = '_self';
30 + $topic_status = bbp_get_topic_status( $current_topic_id );
36 31 if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
37 32 $edit_link = get_edit_post_link( $current_topic_id );
38 33 $target = '_blank';
39 34 }
@@ -38,58 +33,94 @@
38 33 $target = '_blank';
39 34 }
40 35 ?>
41 36 <div class="left-content">
37 + <span class="topic-status">
38 + <?php
39 + // Return the Topic status icon Open, Close, Hidden (spam & pending) and which topic has No reply, is Resolved, is Unresolved.
40 + if ( bbp_is_topic_closed( $current_topic_id ) ) {
41 + echo '<span class="dashicons dashicons-dismiss" title="'.esc_attr__('Status: Closed.', 'forumax').'"></span>';
42 + } elseif ( bbp_is_topic_spam( $current_topic_id ) || bbp_is_topic_pending( $current_topic_id ) ) {
43 + $hidden_status = bbp_is_topic_spam( $current_topic_id ) ? 'Spam ' : 'Pending ';
44 + echo '<span class="dashicons dashicons-hidden" title="' . esc_attr( $hidden_status . __( 'Status: Topic', 'forumax' ) ) . '"></span>';
45 + } elseif ( bbp_is_topic_open( $current_topic_id ) ) {
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
47 + } else {
48 + echo '<span class="dashicons dashicons-info-outline"></span>';
49 + }
50 + ?>
51 + </span>
42 52 <h4>
43 53 <a href="<?php echo esc_attr( $edit_link ); ?>" target="<?php echo esc_attr( $target ); ?>">
44 -
45 - <?php the_title(); ?>
54 + <?php echo esc_html( get_the_title( $current_topic_id ) ); ?>
46 55 </a>
47 - <?php
48 - $allowed_html = [
49 - 'a' => [
50 - 'href' => [],
51 - 'class' => [],
52 - ],
53 - 'span' => [
54 - 'class' => [],
55 - 'title' => [],
56 - ],
57 - ];
56 + </h4>
57 + <!-- Topic Author -->
58 + <span class="bbpc-author-name">
59 + <?php
60 + esc_html_e( '&nbsp; By: ', 'forumax' );
58 61
59 - echo wp_kses( $approve_btn, $allowed_html );
62 + echo wp_kses_post(
63 + bbp_get_topic_author_link(
64 + array(
65 + 'post_id' => $current_topic_id,
66 + 'type' => 'name',
67 + )
68 + )
69 + );
70 + ?>
71 + </span>
60 72
61 - while ( $replies->have_posts() ) :
62 - $replies->the_post();
63 - $reply_id = get_the_ID();
73 + <?php
74 + // Pending replies count and Approve button
75 + $allowed_html = [
76 + 'a' => [
77 + 'href' => [],
78 + 'class' => [],
79 + ],
80 + 'span' => [
81 + 'class' => [],
82 + 'title' => [],
83 + ],
84 + ];
64 85
65 - if ( bbp_is_reply_pending( $reply_id ) ) {
66 - $pending_replies[] = $reply_id;
67 - }
86 + echo wp_kses( $approve_btn, $allowed_html );
68 87
69 - endwhile;
70 - wp_reset_postdata();
88 + $pending_replies_count = count( $pending_replies );
89 + $reply_count = $total_replies - $pending_replies_count;
90 + ?>
91 + <div
92 + title="<?php echo esc_attr( sprintf(
93 + /* translators: %d: Number of published replies */
94 + __( '%d Published replies', 'forumax' ),
95 + $reply_count
96 + ) ); ?>">
71 97
98 + <span class="bbpc-reply-count bbpc-published-replies">
99 + <?php echo esc_html( $reply_count ); ?>
100 + </span>
101 + </div>
72 102
73 - $pending_replies_count = count( $pending_replies );
74 - $reply_count = $replies->found_posts - $pending_replies_count;
75 - ?>
76 - <div title="<?php echo esc_attr( $reply_count ) . __( ' Published replies', 'bbp-core' ); ?>">
77 - <span class="bbpc-reply-count bbpc-published-replies">
78 - <?php echo esc_html( $reply_count ); ?>
79 - </span>
103 + <?php
104 + if ( $pending_replies_count > 0 ) :
105 + ?>
106 + <div click-target='<?php echo esc_attr( $current_topic_id ); ?>'
107 + title="<?php echo esc_attr( sprintf(
108 + /* translators: %d: Number of Pending replies */
109 + __( '%d Pending replies', 'forumax' ),
110 + $pending_replies_count
111 + ) ); ?>">
112 + <span class="bbpc-reply-count bbpc-pending-replies">
113 + <?php echo esc_html( $pending_replies_count ); ?>
114 + </span>
80 115 </div>
81 - <?php if ( $pending_replies_count > 0 ) : ?>
82 - <div click-target='<?php echo esc_attr( $current_topic_id ); ?>' title="<?php echo esc_attr( $pending_replies_count ) . __( ' Pending replies', 'bbp-core' ); ?>">
83 - <span class="bbpc-reply-count bbpc-pending-replies">
84 - <?php echo esc_html( $pending_replies_count ); ?>
85 - </span>
86 - </div>
87 - <?php endif; ?>
88 - </h4>
116 + <?php
117 + endif;
118 + ?>
119 +
89 120 <ul class="actions">
90 121 <li>
91 - <a href="<?php echo 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' ); ?>">
92 123 <span class="dashicons dashicons-external"></span>
93 124 </a>
94 125 </li>
95 126
@@ -94,9 +125,9 @@
94 125 </li>
95 126
96 127 <?php if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) : ?>
97 128 <li class="delete">
98 - <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' ); ?>">
99 130 <span class="dashicons dashicons-trash"></span>
100 131 </a>
101 132 </li>
102 133 <?php endif; ?>
@@ -101,8 +132,15 @@
101 132 </li>
102 133 <?php endif; ?>
103 134 </ul>
104 135 </div>
136 + <div class="right-content">
137 + <!-- Topic Refresh Time -->
138 + <span class="progress-text">
139 + <?php bbp_topic_freshness_link( $current_topic_id ); ?>
140 + </span>
141 + <!-- ./Topic Refresh Time -->
142 + </div>
105 143 </div>
106 144 <!-- Accordion children -->
107 145 <div class="easydocs-accordion-body nesting-accordion">
108 146 <?php if ( ! empty( $pending_replies_count ) ) : ?>
@@ -108,21 +146,20 @@
108 146 <?php if ( ! empty( $pending_replies_count ) ) : ?>
109 147 <ul class="bbpc-nested-replies" reply-target=<?php echo esc_attr( $current_topic_id ); ?>>
110 148 <?php
111 149 foreach ( $pending_replies as $p_reply ) {
112 - setup_postdata( $p_reply );
113 150 ?>
114 - <li reply-id="<?php the_ID(); ?>" class="bbpc-reply-wrap">
151 + <li reply-id="<?php echo esc_attr( $p_reply ); ?>" class="bbpc-reply-wrap">
115 152 <?php
116 - 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, '...' ) );
117 154 echo ' - ';
118 - the_author();
155 + echo esc_html( bbp_get_reply_author_display_name( $p_reply ) );
119 156 ?>
120 157 <?php
121 158 if ( bbp_is_reply_pending( $p_reply ) ) {
122 - $url = admin_url( 'admin.php' ) . '/Approve_Topic.php?bbpc_approve_reply_id=' . $p_reply;
123 - $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' ) );
124 - }
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 + }
125 162
126 163 $allowed_html = [
127 164 'a' => [
128 165 'href' => [],
@@ -139,10 +176,8 @@
139 176 ?>
140 177 </li>
141 178 <?php
142 179 }
143 -
144 - wp_reset_postdata();
145 180 ?>
146 181 </ul>
147 182 <?php endif; ?>
148 183 </div>