PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.3
Forumax – AI Powered Advanced Community Forum Plugin v2.4.3
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 / Blocks / Render / forum-ajax.php

forum-ajax.php in Forumax – AI Powered Advanced Community Forum Plugin 2.4.3, at includes/Blocks/Render/forum-ajax.php

545 lines 23.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace admin\Blocks\Render;
3
4 use WP_Query;
5
6 class Forum_Ajax {
7 public function render_forum_ajax( $attributes, $content ) {
8 // Upsell logic for frontend when Pro is not active.
9 if ( ! class_exists( 'Forumax_Pro' ) ) {
10 $upsell_img = defined( 'FORUMAX_IMG' ) ? FORUMAX_IMG . 'upsell-forum-ajax.png' : '';
11 $upgrade_url = admin_url( 'admin.php?page=forumax-pricing' );
12
13 ob_start();
14 ?>
15 <style>
16 .bbpc-upsell-container {
17 position: relative;
18 display: flex;
19 justify-content: center;
20 align-items: center;
21 min-height: 300px;
22 background: #f5f5f5;
23 border: 1px dashed #ccc;
24 overflow: hidden;
25 border-radius: 8px;
26 margin: 20px 0;
27 }
28
29 .bbpc-upsell-container img {
30 max-width: 100%;
31 height: auto;
32 display: block;
33 opacity: 0.5;
34 }
35
36 .bbpc-upsell-btn-wrapper {
37 position: absolute;
38 top: 50%;
39 left: 50%;
40 transform: translate(-50%, -50%);
41 z-index: 10;
42 }
43
44 .bbpc-upgrade-btn-frontend {
45 background: linear-gradient(90deg, #172473 0%, #0fa2d0 100%) !important;
46 border: none !important;
47 color: #fff !important;
48 padding: 15px 20px !important;
49 font-size: 18px !important;
50 font-weight: 500 !important;
51 border-radius: 4px !important;
52 text-decoration: none !important;
53 box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) !important;
54 transition: all 0.3s ease !important;
55 display: inline-block !important;
56 line-height: 1 !important;
57 }
58
59 .bbpc-upgrade-btn-frontend:hover {
60 transform: translate(-2px, -2px);
61 box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3) !important;
62 color: #fff !important;
63 background: linear-gradient(80deg, #0fa2d0 0%, #172473 100%) !important;
64 }
65 </style>
66 <div class="bbpc-upsell-container">
67 <?php if ( $upsell_img ) : ?>
68 <img src="<?php echo esc_url( $upsell_img ); ?>" alt="<?php esc_attr_e( 'Upgrade to Pro', 'bbp-core' ); ?>">
69 <?php endif; ?>
70 <div class="bbpc-upsell-btn-wrapper">
71 <a href="<?php echo esc_url( $upgrade_url ); ?>" class="bbpc-upgrade-btn-frontend">
72 <?php esc_html_e( 'Upgrade to Pro', 'bbp-core' ); ?>
73 </a>
74 </div>
75 </div>
76 <?php
77 return ob_get_clean();
78 }
79
80 try {
81 if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) {
82 if ( defined( 'FORUMAX_FRONT_ASS' ) ) {
83 wp_register_style( 'bbpc-el-widgets', FORUMAX_STYLES . 'frontend/el-widgets.css', array(), FORUMAX_VERSION );
84 }
85 }
86
87 wp_enqueue_style( 'bbpc-el-widgets' );
88
89 // Extract settings with defaults
90 $ppp2 = isset( $attributes['ppp2'] ) ? absint( $attributes['ppp2'] ) : 9;
91 $order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC';
92 $orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date';
93 $filter_btns = isset( $attributes['filter_btns'] ) ? (bool) $attributes['filter_btns'] : true;
94 $show_filter_all = isset( $attributes['show_filter_all'] ) ? (bool) $attributes['show_filter_all'] : true;
95 $show_filter_popular = isset( $attributes['show_filter_popular'] ) ? (bool) $attributes['show_filter_popular'] : true;
96 $show_filter_featured = isset( $attributes['show_filter_featured'] ) ? (bool) $attributes['show_filter_featured'] : true;
97 $show_filter_recent = isset( $attributes['show_filter_recent'] ) ? (bool) $attributes['show_filter_recent'] : true;
98 $show_filter_unloved = isset( $attributes['show_filter_unloved'] ) ? (bool) $attributes['show_filter_unloved'] : true;
99 $show_filter_loved = isset( $attributes['show_filter_loved'] ) ? (bool) $attributes['show_filter_loved'] : true;
100 $label_all = ! empty( $attributes['label_all'] ) ? $attributes['label_all'] : __( 'All', 'bbp-core' );
101 $label_popular = ! empty( $attributes['label_popular'] ) ? $attributes['label_popular'] : __( 'Popular', 'bbp-core' );
102 $label_featured = ! empty( $attributes['label_featured'] ) ? $attributes['label_featured'] : __( 'Featured', 'bbp-core' );
103 $label_recent = ! empty( $attributes['label_recent'] ) ? $attributes['label_recent'] : __( 'Recent', 'bbp-core' );
104 $label_unloved = ! empty( $attributes['label_unloved'] ) ? $attributes['label_unloved'] : __( 'Unloved', 'bbp-core' );
105 $label_loved = ! empty( $attributes['label_loved'] ) ? $attributes['label_loved'] : __( 'Loved', 'bbp-core' );
106 $show_views = isset( $attributes['show_views'] ) ? (bool) $attributes['show_views'] : true;
107 $show_likes = isset( $attributes['show_likes'] ) ? (bool) $attributes['show_likes'] : true;
108 $show_replies = isset( $attributes['show_replies'] ) ? (bool) $attributes['show_replies'] : true;
109 $show_author = isset( $attributes['show_author'] ) ? (bool) $attributes['show_author'] : true;
110 $show_time = isset( $attributes['show_time'] ) ? (bool) $attributes['show_time'] : true;
111 $show_parent_forum = isset( $attributes['show_parent_forum'] ) ? (bool) $attributes['show_parent_forum'] : true;
112 $enable_card_hover = isset( $attributes['enable_card_hover'] ) ? (bool) $attributes['enable_card_hover'] : true;
113 $no_posts_message = ! empty( $attributes['no_posts_message'] ) ? $attributes['no_posts_message'] : __( 'No topics found.', 'bbp-core' );
114 $hide_reach_mobile = isset( $attributes['hide_reach_mobile'] ) ? (bool) $attributes['hide_reach_mobile'] : false;
115 $forum_filter_ids = ! empty( $attributes['forum_filter_ids'] ) ? $attributes['forum_filter_ids'] : '';
116 $exclude_forum_ids = ! empty( $attributes['exclude_forum_ids'] ) ? $attributes['exclude_forum_ids'] : '';
117 $show_excerpt = isset( $attributes['show_excerpt'] ) ? (bool) $attributes['show_excerpt'] : false;
118 $excerpt_length = isset( $attributes['excerpt_length'] ) ? absint( $attributes['excerpt_length'] ) : 20;
119 $show_avatar = isset( $attributes['show_avatar'] ) ? (bool) $attributes['show_avatar'] : false;
120 $show_status_badge = isset( $attributes['show_status_badge'] ) ? (bool) $attributes['show_status_badge'] : false;
121 $load_more_enabled = isset( $attributes['load_more'] ) ? (bool) $attributes['load_more'] : false;
122 $load_more_text = ! empty( $attributes['load_more_text'] ) ? $attributes['load_more_text'] : __( 'Load More', 'bbp-core' );
123
124 // CSS sanitization helper
125 $sanitize_css_color = function ( $color ) {
126 $color = trim( (string) $color );
127 if ( empty( $color ) ) {
128 return '';
129 }
130 if ( preg_match( '/^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/', $color ) ) {
131 return $color;
132 }
133 if ( preg_match( '/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/', $color ) ) {
134 return $color;
135 }
136 return '';
137 };
138
139 // Sanitize color attributes.
140 $forum_title_color = $sanitize_css_color( isset( $attributes['forum_title_color'] ) ? $attributes['forum_title_color'] : '' );
141 $forum_title_hover_color = $sanitize_css_color( isset( $attributes['forum_title_hover_color'] ) ? $attributes['forum_title_hover_color'] : '' );
142 $forum_meta_color = $sanitize_css_color( isset( $attributes['forum_meta_color'] ) ? $attributes['forum_meta_color'] : '' );
143 $parent_forum_color = $sanitize_css_color( isset( $attributes['parent_forum_color'] ) ? $attributes['parent_forum_color'] : '' );
144 $parent_forum_color_hover = $sanitize_css_color( isset( $attributes['parent_forum_color_hover'] ) ? $attributes['parent_forum_color_hover'] : '' );
145 $card_bg_color = $sanitize_css_color( isset( $attributes['card_bg_color'] ) ? $attributes['card_bg_color'] : '' );
146 $filter_bar_bg_color = $sanitize_css_color( isset( $attributes['filter_bar_bg_color'] ) ? $attributes['filter_bar_bg_color'] : '' );
147 $active_filter_color = $sanitize_css_color( isset( $attributes['active_filter_color'] ) ? $attributes['active_filter_color'] : '' );
148 $reach_color = $sanitize_css_color( isset( $attributes['reach_color'] ) ? $attributes['reach_color'] : '' );
149
150 $unique_id = uniqid( 'bbpc-forum-' );
151
152 // Check constants.
153 if ( ! defined( 'FORUMAX_VEND' ) || ! defined( 'FORUMAX_FRONT_ASS' ) || ! defined( 'FORUMAX_VERSION' ) ) {
154 return '<div class="alert alert-warning">' . esc_html__( 'Required constants missing.', 'bbp-core' ) . '</div>';
155 }
156
157 // Enqueue styles/scripts.
158 if ( ! wp_style_is( 'elegant-icon', 'registered' ) ) {
159 wp_register_style( 'elegant-icon', FORUMAX_VEND . '/elegant-icon/style.css' );
160 }
161 if ( ! wp_script_is( 'bbpc-ajax', 'registered' ) ) {
162 wp_register_script( 'bbpc-ajax', FORUMAX_FRONT_ASS . 'js/ajax.js', array( 'jquery' ), FORUMAX_VERSION, true );
163 }
164
165 wp_enqueue_style( 'elegant-icon' );
166 wp_enqueue_script( 'bbpc-ajax' );
167
168 // Inline Styles
169 $styles = '';
170 $id = '#' . $unique_id;
171
172 if ( $forum_title_color ) {
173 $styles .= "{$id} .single-forum-post-widget .post-title a { color: {$forum_title_color} !important; }";
174 }
175 if ( $forum_title_hover_color ) {
176 $styles .= "{$id} .single-forum-post-widget .post-title a:hover { color: {$forum_title_hover_color} !important; }";
177 $styles .= "{$id} .single-forum-post-widget:hover .post-title a { color: {$forum_title_hover_color} !important; }";
178 }
179 if ( $forum_meta_color ) {
180 $styles .= "{$id} .single-forum-post-widget .post-info .author, {$id} .single-forum-post-widget .post-info .post-time { color: {$forum_meta_color} !important; }";
181 }
182 if ( $parent_forum_color ) {
183 $styles .= "{$id} .post-content .post-category a { color: {$parent_forum_color} !important; }";
184 }
185 if ( $parent_forum_color_hover ) {
186 $styles .= "{$id} .post-content .post-category a:hover { color: {$parent_forum_color_hover} !important; }";
187 }
188 if ( $card_bg_color ) {
189 $styles .= "{$id} .single-forum-post-widget { background-color: {$card_bg_color} !important; }";
190 }
191 if ( $filter_bar_bg_color ) {
192 $styles .= "{$id} .post-filter-widget { background-color: {$filter_bar_bg_color} !important; }";
193 }
194 if ( $active_filter_color ) {
195 $styles .= "{$id} .single-filter-item a.data-active { color: {$active_filter_color} !important; }";
196 }
197 if ( $reach_color ) {
198 $styles .= "{$id} .post-reach > div { color: {$reach_color} !important; }";
199 }
200
201 // Typography.
202 if ( ! empty( $attributes['title_font_size'] ) ) {
203 $size = absint( $attributes['title_font_size'] );
204 $styles .= "{$id} .single-forum-post-widget .post-title a { font-size: {$size}px !important; }";
205 }
206 if ( ! empty( $attributes['meta_font_size'] ) ) {
207 $size = absint( $attributes['meta_font_size'] );
208 $styles .= "{$id} .single-forum-post-widget .post-info > div { font-size: {$size}px !important; }";
209 }
210
211 // Spacing.
212 if ( ! empty( $attributes['card_border_radius'] ) ) {
213 $radius = absint( $attributes['card_border_radius'] );
214 $styles .= "{$id} .single-forum-post-widget { border-radius: {$radius}px !important; }";
215 }
216 if ( ! empty( $attributes['card_gap'] ) ) {
217 $gap = absint( $attributes['card_gap'] );
218 $styles .= "{$id} .single-forum-post-widget { margin-top: {$gap}px !important; }";
219 }
220
221 // Card hover disabled.
222 if ( ! $enable_card_hover ) {
223 $styles .= "{$id} .single-forum-post-widget:hover { transform: none !important; box-shadow: 0 1.6px 3.5px 0 #334d7226, 0 0.5px 1px 0 #334d721a !important; }";
224 $styles .= "{$id} .single-forum-post-widget:hover .post-title h6 a { color: inherit !important; }";
225 }
226
227 // Responsive.
228 if ( $hide_reach_mobile ) {
229 $styles .= "@media (max-width: 768px) { {$id} .single-forum-post-widget .post-reach { display: none !important; } }";
230 }
231
232 // Status badge styles.
233 if ( $show_status_badge ) {
234 $styles .= "{$id} .frmx-status-badge { display: inline-block !important; padding: 2px 10px !important; border-radius: 12px !important; font-size: 11px !important; font-weight: 600 !important; line-height: 1.5 !important; margin-left: 8px !important; vertical-align: middle !important; }";
235 $styles .= "{$id} .frmx-status-badge--open { background-color: #dcfce7 !important; color: #166534 !important; }";
236 $styles .= "{$id} .frmx-status-badge--closed { background-color: #fee2e2 !important; color: #991b1b !important; }";
237 $styles .= "{$id} .frmx-status-badge--resolved { background-color: #dbeafe !important; color: #1e40af !important; }";
238 }
239
240 // Excerpt styles.
241 if ( $show_excerpt ) {
242 $styles .= "{$id} .frmx-topic-excerpt { font-size: 13px !important; color: #6b7280 !important; margin-top: 6px !important; line-height: 1.5 !important; }";
243 }
244
245 // Load More button styles.
246 if ( $load_more_enabled ) {
247 $styles .= "{$id} .frmx-load-more-wrap { text-align: center !important; margin-top: 20px !important; }";
248 $styles .= "{$id} .frmx-load-more-btn { display: inline-block !important; padding: 10px 28px !important; background: #3b82f6 !important; color: #fff !important; border: none !important; border-radius: 6px !important; font-size: 14px !important; font-weight: 500 !important; cursor: pointer !important; transition: background 0.3s ease !important; text-decoration: none !important; }";
249 $styles .= "{$id} .frmx-load-more-btn:hover { background: #2563eb !important; }";
250 }
251
252 // Query
253 $query_args = array(
254 'post_type' => 'topic',
255 'posts_per_page' => $load_more_enabled ? -1 : $ppp2,
256 'order' => $order,
257 'orderby' => $orderby,
258 );
259
260 // Forum ID filter (include).
261 if ( ! empty( $forum_filter_ids ) ) {
262 $include_ids = array_map( 'absint', array_filter( explode( ',', $forum_filter_ids ) ) );
263 if ( ! empty( $include_ids ) ) {
264 $query_args['meta_query'][] = array(
265 'key' => '_bbp_forum_id',
266 'value' => $include_ids,
267 'compare' => 'IN',
268 'type' => 'NUMERIC',
269 );
270 }
271 }
272
273 // Forum ID filter (exclude).
274 if ( ! empty( $exclude_forum_ids ) ) {
275 $exclude_ids = array_map( 'absint', array_filter( explode( ',', $exclude_forum_ids ) ) );
276 if ( ! empty( $exclude_ids ) ) {
277 $query_args['meta_query'][] = array(
278 'key' => '_bbp_forum_id',
279 'value' => $exclude_ids,
280 'compare' => 'NOT IN',
281 'type' => 'NUMERIC',
282 );
283 }
284 }
285
286 $topics = new WP_Query( $query_args );
287
288 $wrapper_attributes = get_block_wrapper_attributes( array(
289 'class' => 'forum-post-widget',
290 'id' => $unique_id,
291 ) );
292
293 $total_topics = $topics->post_count;
294
295 ob_start();
296
297 // Output styles.
298 if ( ! empty( $styles ) ) {
299 echo '<style>' . $styles . '</style>';
300 }
301 ?>
302
303 <div <?php echo $wrapper_attributes; ?> data_id="<?php echo esc_attr( $unique_id ); ?>">
304
305 <?php if ( $filter_btns ) : ?>
306 <div class="post-filter-widget mb-20">
307 <?php if ( $show_filter_all ) : ?>
308 <div class="single-filter-item">
309 <a href="#" id="all_filt" data-forum="all" class="data-active">
310 <i class="icon_grid-2x2"></i><?php echo esc_html( $label_all ); ?>
311 </a>
312 </div>
313 <?php endif; ?>
314 <?php if ( $show_filter_popular ) : ?>
315 <div class="single-filter-item">
316 <a href="#" id="populer_filt" data-forum="popular">
317 <i class="icon_easel"></i><?php echo esc_html( $label_popular ); ?>
318 </a>
319 </div>
320 <?php endif; ?>
321 <?php if ( $show_filter_featured ) : ?>
322 <div class="single-filter-item">
323 <a href="#" id="featured_filt" data-forum="featured">
324 <i class="icon_ribbon_alt"></i><?php echo esc_html( $label_featured ); ?>
325 </a>
326 </div>
327 <?php endif; ?>
328 <?php if ( $show_filter_recent ) : ?>
329 <div class="single-filter-item">
330 <a href="#" id="recent_filt" data-forum="recent">
331 <i class="icon_clock_alt"></i><?php echo esc_html( $label_recent ); ?>
332 </a>
333 </div>
334 <?php endif; ?>
335 <?php if ( $show_filter_unloved ) : ?>
336 <div class="single-filter-item">
337 <a href="#" id="unloved_filt" data-forum="unloved">
338 <i class="icon_close_alt2"></i><?php echo esc_html( $label_unloved ); ?>
339 </a>
340 </div>
341 <?php endif; ?>
342 <?php if ( $show_filter_loved ) : ?>
343 <div class="single-filter-item">
344 <a href="#" id="loved_filt" data-forum="loved">
345 <i class="icon_check_alt2"></i><?php echo esc_html( $label_loved ); ?>
346 </a>
347 </div>
348 <?php endif; ?>
349 </div>
350 <?php endif; ?>
351
352 <div id="aj-post-filter-widget">
353 <?php
354 if ( $topics->have_posts() ) :
355 $i = 0;
356 while ( $topics->have_posts() ) :
357 $topics->the_post();
358 $topic_id = $topics->posts[ $i ]->ID;
359 $vote_count = get_post_meta( $topic_id, 'bbpv-votes', true );
360
361 // Safe get forum ID.
362 $forum_id = function_exists( 'bbp_get_topic_forum_id' ) ? bbp_get_topic_forum_id() : 0;
363 // Safe get forum title.
364 $forum_title = '';
365 if ( function_exists( 'bbp_get_topic_forum_title' ) ) {
366 $forum_title = bbp_get_topic_forum_title();
367 } elseif ( function_exists( 'bbp_get_forum_title' ) ) {
368 $forum_title = bbp_get_forum_title( $forum_id );
369 }
370
371 $hover_class = $enable_card_hover ? ' wow fadeInUp' : '';
372 ?>
373 <div class="single-forum-post-widget<?php echo esc_attr( $hover_class ); ?>"
374 <?php if ( $load_more_enabled && $i >= $ppp2 ) : ?> style="display: none !important;" data-frmx-hidden="1"<?php endif; ?>>
375 <div class="post-content">
376 <div class="post-title">
377 <h6>
378 <a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a>
379 <?php if ( $show_status_badge ) :
380 $topic_status = get_post_status( $topic_id );
381 $is_resolved = get_post_meta( $topic_id, '_bbp_topic_status', true );
382 if ( 'resolved' === $is_resolved ) :
383 ?>
384 <span class="frmx-status-badge frmx-status-badge--resolved"><?php esc_html_e( 'Resolved', 'bbp-core' ); ?></span>
385 <?php elseif ( 'closed' === $topic_status ) : ?>
386 <span class="frmx-status-badge frmx-status-badge--closed"><?php esc_html_e( 'Closed', 'bbp-core' ); ?></span>
387 <?php else : ?>
388 <span class="frmx-status-badge frmx-status-badge--open"><?php esc_html_e( 'Open', 'bbp-core' ); ?></span>
389 <?php endif; endif; ?>
390 </h6>
391 </div>
392 <?php if ( $show_excerpt ) :
393 $raw_content = get_the_content( null, false, $topic_id );
394 $excerpt = wp_trim_words( wp_strip_all_tags( $raw_content ), $excerpt_length, '&hellip;' );
395 ?>
396 <p class="frmx-topic-excerpt"><?php echo esc_html( $excerpt ); ?></p>
397 <?php endif; ?>
398 <div class="post-info">
399 <?php if ( $show_author ) : ?>
400 <div class="author">
401 <?php
402 $author_id = get_post_field( 'post_author', $topic_id );
403 if ( $show_avatar && $author_id ) {
404 echo get_avatar( $author_id, 24 );
405 } elseif ( defined( 'FORUMAX_IMG' ) ) {
406 ?>
407 <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/user-circle-alt.svg' ); ?>"
408 alt="<?php esc_attr_e( 'User icon', 'bbp-core' ); ?>">
409 <?php } ?>
410 <?php
411 if ( function_exists( 'bbp_get_topic_author_link' ) ) {
412 echo wp_kses_post( bbp_get_topic_author_link(
413 array(
414 'post_id' => $topic_id,
415 'type' => 'name',
416 )
417 ) );
418 }
419 ?>
420 </div>
421 <?php endif; ?>
422
423 <?php if ( $show_time ) : ?>
424 <div class="post-time">
425 <?php if ( defined( 'FORUMAX_IMG' ) ) : ?>
426 <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/time-outline.svg' ); ?>"
427 alt="<?php esc_attr_e( 'Time icon', 'bbp-core' ); ?>">
428 <?php endif; ?>
429 <?php
430 if ( function_exists( 'bbp_topic_last_active_time' ) ) {
431 bbp_topic_last_active_time( get_the_ID() );
432 } elseif ( function_exists( 'bbp_forum_last_active_time' ) ) {
433 bbp_forum_last_active_time( get_the_ID() );
434 }
435 ?>
436 </div>
437 <?php endif; ?>
438 </div>
439
440 <?php if ( $show_parent_forum ) : ?>
441 <div class="post-category">
442 <a href="<?php echo esc_url( get_the_permalink( $forum_id ) ); ?>">
443 <?php echo get_the_post_thumbnail( $forum_id ); ?>
444 <?php echo esc_html( $forum_title ); ?>
445 </a>
446 </div>
447 <?php endif; ?>
448 </div>
449
450 <?php if ( $show_views || $show_likes || $show_replies ) : ?>
451 <div class="post-reach">
452 <?php if ( $show_views ) : ?>
453 <div class="post-view">
454 <?php if ( defined( 'FORUMAX_IMG' ) ) : ?>
455 <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/eye-outline.svg' ); ?>"
456 alt="<?php esc_attr_e( 'Views icon', 'bbp-core' ); ?>">
457 <?php endif; ?>
458 <?php
459 if ( function_exists( 'forumax_topic_view_count' ) ) {
460 forumax_topic_view_count( $topic_id );
461 }
462 echo '&nbsp;';
463 esc_html_e( 'Views', 'bbp-core' );
464 ?>
465 </div>
466 <?php endif; ?>
467
468 <?php if ( $show_likes ) : ?>
469 <div class="post-like">
470 <?php if ( defined( 'FORUMAX_IMG' ) ) : ?>
471 <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/thumbs-up-outline.svg' ); ?>"
472 alt="<?php esc_attr_e( 'Likes icon', 'bbp-core' ); ?>">
473 <?php endif; ?>
474 <?php
475 echo esc_html( $vote_count ? $vote_count : '0' );
476 echo '&nbsp;';
477 esc_html_e( 'Likes', 'bbp-core' );
478 ?>
479 </div>
480 <?php endif; ?>
481
482 <?php if ( $show_replies ) : ?>
483 <div class="post-comment">
484 <?php if ( defined( 'FORUMAX_IMG' ) ) : ?>
485 <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/chatbubbles-outline.svg' ); ?>"
486 alt="<?php esc_attr_e( 'Replies icon', 'bbp-core' ); ?>">
487 <?php endif; ?>
488 <?php
489 if ( function_exists( 'bbp_topic_reply_count' ) ) {
490 bbp_topic_reply_count( $topic_id );
491 }
492 echo '&nbsp;';
493 esc_html_e( 'Replies', 'bbp-core' );
494 ?>
495 </div>
496 <?php endif; ?>
497 </div>
498 <?php endif; ?>
499 </div>
500 <?php
501 $i++;
502 endwhile;
503 wp_reset_postdata();
504 else :
505 ?>
506 <div class="alert alert-warning"><?php echo esc_html( $no_posts_message ); ?></div>
507 <?php endif; ?>
508 </div>
509
510 <?php if ( $load_more_enabled && $total_topics > $ppp2 ) : ?>
511 <div class="frmx-load-more-wrap">
512 <button type="button" class="frmx-load-more-btn"
513 data-per-page="<?php echo esc_attr( $ppp2 ); ?>"
514 data-total="<?php echo esc_attr( $total_topics ); ?>"
515 data-container="#<?php echo esc_attr( $unique_id ); ?> #aj-post-filter-widget">
516 <?php echo esc_html( $load_more_text ); ?>
517 </button>
518 </div>
519 <?php endif; ?>
520
521 <?php if ( $load_more_enabled && $total_topics > $ppp2 ) :
522 $load_more_js = '
523 jQuery(document).on("click", "#' . esc_js( $unique_id ) . ' .frmx-load-more-btn", function(e) {
524 e.preventDefault();
525 var $wrapper = jQuery("#' . esc_js( $unique_id ) . '");
526 var perPage = parseInt(jQuery(this).attr("data-per-page"), 10) || 9;
527 var $hidden = $wrapper.find("[data-frmx-hidden=1]");
528 $hidden.slice(0, perPage).each(function() {
529 jQuery(this).removeAttr("style").removeAttr("data-frmx-hidden");
530 });
531 if ($wrapper.find("[data-frmx-hidden=1]").length === 0) {
532 jQuery(this).parent().hide();
533 }
534 });
535 ';
536 wp_add_inline_script( 'bbpc-ajax', $load_more_js );
537 endif; ?>
538 </div>
539 <?php
540 return ob_get_clean();
541 } catch ( \Throwable $e ) {
542 return '<div>Error rendering block: ' . esc_html( $e->getMessage() ) . '</div>';
543 }
544 }
545 }