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 / Elementor / Forum_Ajax.php

Forum_Ajax.php in Forumax – AI Powered Advanced Community Forum Plugin 1.2.6, at includes/Elementor/Forum_Ajax.php

358 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace admin\Elementor;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Widget_Base;
7 use WP_Query;
8
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 class Forum_Ajax extends Widget_Base {
15 public function get_name() {
16 return 'ama_ajax_forum';
17 }
18
19 public function get_title() {
20 return esc_html__( 'BBPC Ajax Forums', 'bbp-core' );
21 }
22
23 public function get_icon() {
24 return 'bbpc_icon_ama_ajax_forum';
25 }
26
27 public function get_keywords() {
28 return [ 'forum', 'ajax' ];
29 }
30
31 public function get_categories() {
32 return [ 'bbp-core' ];
33 }
34
35 public function get_style_depends() {
36 return [ 'bbpc-el-widgets' ];
37 }
38
39 public function get_script_depends() {
40 return [ 'bbpc-ajax' ];
41 }
42
43 protected function register_controls() {
44 /**
45 * Content section
46 */
47 $this->start_controls_section(
48 'content_sec', [
49 'label' => esc_html__( 'Content Section', 'bbp-core' ),
50 ]
51 );
52
53 $this->add_control(
54 'ppp2', [
55 'label' => esc_html__( 'Show Forums', 'bbp-core' ),
56 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'bbp-core' ),
57 'type' => \Elementor\Controls_Manager::NUMBER,
58 'label_block' => true,
59 'default' => 9
60 ]
61 );
62
63 $this->add_control(
64 'order', [
65 'label' => esc_html__( 'Order', 'bbp-core' ),
66 'type' => \Elementor\Controls_Manager::SELECT,
67 'options' => [
68 'ASC' => 'ASC',
69 'DESC' => 'DESC'
70 ],
71 'default' => 'ASC'
72 ]
73 );
74
75 // button show hide switcher
76 $this->add_control(
77 'filter_btns',
78 [
79 'label' => esc_html__( 'Tab Filter', 'bbp-core' ),
80 'type' => \Elementor\Controls_Manager::SWITCHER,
81 'label_on' => esc_html__( 'Show', 'bbp-core' ),
82 'label_off' => esc_html__( 'Hide', 'bbp-core' ),
83 'return_value' => 'yes',
84 'default' => 'yes',
85 ]
86 );
87
88 $this->end_controls_section();
89
90 /**
91 * Styling section starts
92 */
93 $this->start_controls_section(
94 'styling_sec', [
95 'label' => esc_html__( 'Title Style', 'bbp-core' ),
96 'tab' => Controls_Manager::TAB_STYLE,
97 ]
98 );
99 //forum title
100 $this->add_control(
101 'forum_heading',
102 [
103 'label' => esc_html__( 'Forum Title', 'bbp-core' ),
104 'type' => \Elementor\Controls_Manager::HEADING,
105 'separator' => 'before',
106 ]
107 );
108
109
110 $this->add_control(
111 'forum_title_color',
112 [
113 'label' => esc_html__( 'Color', 'bbp-core' ),
114 'type' => \Elementor\Controls_Manager::COLOR,
115 'selectors' => [
116 '{{WRAPPER}} .single-forum-post-widget .post-title a' => 'color: {{VALUE}}',
117 ],
118 ]
119 );
120
121 $this->add_control(
122 'forum_title_hover_color',
123 [
124 'label' => esc_html__( 'Hover Color', 'bbp-core' ),
125 'type' => \Elementor\Controls_Manager::COLOR,
126 'selectors' => [
127 '{{WRAPPER}} .single-forum-post-widget .post-title a:hover' => 'color: {{VALUE}}',
128 ],
129 ]
130 );
131
132 $this->add_group_control(
133 \Elementor\Group_Control_Typography::get_type(),
134 [
135 'name' => 'forum_title_typography',
136 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-title a',
137 ]
138 );
139
140 // Forum meta
141 $this->add_control(
142 'forum_meta',
143 [
144 'label' => esc_html__( 'Forum Meta', 'bbp-core' ),
145 'type' => \Elementor\Controls_Manager::HEADING,
146 'separator' => 'before',
147 ]
148 );
149
150 $this->add_control(
151 'forum_meta_color',
152 [
153 'label' => esc_html__( 'Color', 'bbp-core' ),
154 'type' => \Elementor\Controls_Manager::COLOR,
155 'selectors' => [
156 '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time' => 'color: {{VALUE}}',
157 ],
158 ]
159 );
160
161
162 $this->add_group_control(
163 \Elementor\Group_Control_Typography::get_type(),
164 [
165 'name' => 'forum_meta_typography',
166 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time',
167 ]
168 );
169
170 //parent forum
171 $this->add_control(
172 'parent_forum',
173 [
174 'label' => esc_html__( 'Parent Forum', 'bbp-core' ),
175 'type' => \Elementor\Controls_Manager::HEADING,
176 'separator' => 'before',
177 ]
178 );
179
180 $this->add_control(
181 'parent_forum_color',
182 [
183 'label' => esc_html__( 'Color', 'bbp-core' ),
184 'type' => \Elementor\Controls_Manager::COLOR,
185 'selectors' => [
186 '{{WRAPPER}} .post-content .post-category a' => 'color: {{VALUE}}',
187 ],
188 ]
189 );
190
191 $this->add_control(
192 'parent_forum_color_hover',
193 [
194 'label' => esc_html__( 'Hover color', 'bbp-core' ),
195 'type' => \Elementor\Controls_Manager::COLOR,
196 'selectors' => [
197 '{{WRAPPER}} .post-content .post-category a:hover' => 'color: {{VALUE}}',
198 ],
199 ]
200 );
201
202 $this->add_group_control(
203 \Elementor\Group_Control_Typography::get_type(),
204 [
205 'name' => 'parent_forum_typo',
206 'selector' => '{{WRAPPER}} .post-content .post-category a',
207 ]
208 );
209
210 $this->end_controls_section();
211 }
212
213 protected function render() {
214 $settings = $this->get_settings();
215 $filter_btns = $settings['filter_btns'] ?? true;
216
217 $topics = new WP_Query( array(
218 'post_type' => 'topic',
219 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9,
220 'order' => $settings['order'] ? $settings['order'] : 'DESC',
221 ) );
222 ?>
223
224 <div class="forum-post-widget" data_id="<?php echo esc_attr( $this->get_id() ); ?>">
225
226 <?php
227 if ( $filter_btns == true ) :
228 ?>
229 <div class="post-filter-widget mb-20 wow fadeInUp">
230 <div class="single-filter-item">
231 <a href="#" id="all_filt" data-forum="all" class="data-active">
232 <i class="icon_grid-2x2"></i><?php _e( 'All', 'bbp-core' ) ?>
233 </a>
234 </div>
235 <div class="single-filter-item">
236 <a href="#" id="populer_filt" data-forum="popular">
237 <i class="icon_easel"></i><?php _e( 'Popular', 'bbp-core' ) ?>
238 </a>
239 </div>
240 <div class="single-filter-item">
241 <a href="#" id="featured_filt" data-forum="featured">
242 <i class="icon_ribbon_alt"></i><?php _e( 'Featured', 'bbp-core' ) ?>
243 </a>
244 </div>
245 <div class="single-filter-item">
246 <a href="#" id="recent_filt" data-forum="recent">
247 <i class="icon_clock_alt"></i><?php _e( 'Recent', 'bbp-core' ) ?>
248 </a>
249 </div>
250 <div class="single-filter-item">
251 <a href="#" id="unsolved_filt" data-forum="unsolved">
252 <i class="icon_close_alt2"></i><?php _e( 'Unsolved', 'bbp-core' ) ?>
253 </a>
254 </div>
255 <div class="single-filter-item">
256 <a href="#" id="solved_filt" data-forum="solved">
257 <i class="icon_check_alt2"></i><?php _e( 'Solved', 'bbp-core' ) ?>
258 </a>
259 </div>
260 </div>
261 <?php
262 endif;
263 ?>
264
265 <div id="aj-post-filter-widget">
266 <?php
267 $delay = 0.0;
268 $i = 0;
269 while ( $topics->have_posts() ) : $topics->the_post();
270 $item_id = get_the_ID();
271 $author_id = get_post_field( 'post_author', $item_id );
272 $topic_id = $topics->posts[ $i ]->ID;
273 $vote_count = get_post_meta( $topic_id, "bbpv-votes", true );
274 $forum_id = bbp_get_topic_forum_id();
275 ?>
276 <div class="single-forum-post-widget wow fadeInUp" data-wow-delay="<?php echo $delay ?>s">
277 <div class="post-content">
278 <div class="post-title">
279 <h6><a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a></h6>
280 </div>
281 <div class="post-info">
282 <div class="author">
283 <img src="<?php echo BBPC_IMG ?>/forum_tab/user-circle-alt.svg" alt="<?php esc_attr_e( 'User circle alt icon', 'bbpc-core' ); ?>">
284 <?php
285 echo bbp_get_topic_author_link(
286 array(
287 'post_id' => $topic_id,
288 'type' => 'name'
289 )
290 );
291 ?>
292 </div>
293
294 <div class="post-time">
295 <img src="<?php echo BBPC_IMG ?>/forum_tab/time-outline.svg" alt="<?php esc_attr_e( 'Time outline icon', 'bbpc-core' ); ?>">
296 <?php echo bbp_forum_last_active_time( get_the_ID() ); ?>
297 </div>
298 </div>
299
300 <div class="post-category">
301 <a href="<?php echo get_the_permalink( $forum_id ) ?>">
302 <?php echo get_the_post_thumbnail( $forum_id ); ?>
303 <?php echo bbp_get_topic_forum_title(); ?>
304 </a>
305 </div>
306 </div>
307 <div class="post-reach">
308 <div class="post-view">
309 <img src="<?php echo BBPC_IMG ?>/forum_tab/eye-outline.svg" alt="<?php esc_attr_e( 'Eye outline icon', 'bbpc-core' ); ?>">
310
311 <?php
312 bbp_topic_view_count( $topic_id );
313 echo '&nbsp;';
314 _e( 'Views', 'bbp-core' );
315 ?>
316 </div>
317 <div class="post-like">
318 <img src="<?php echo BBPC_IMG ?>/forum_tab/thumbs-up-outline.svg" alt="<?php esc_attr_e( 'Thumbs-up outline icon', 'bbpc-core' ); ?>">
319
320 <?php
321 if ( $vote_count ) {
322 echo $vote_count;
323 } else {
324 echo "0";
325 }
326
327 echo '&nbsp;';
328 _e( 'Likes', 'bbp-core' );
329 ?>
330 </div>
331 <div class="post-comment">
332 <img src="<?php echo BBPC_IMG ?>/forum_tab/chatbubbles-outline.svg" alt="<?php esc_attr_e( 'Chat bubbles icon', 'bbpc-core' ); ?>">
333
334 <?php
335 bbp_topic_reply_count( $topic_id );
336 echo '&nbsp;';
337 _e( 'Replies', 'bbp-core' );
338 ?>
339 </div>
340 </div>
341 </div>
342
343 <?php
344 $delay += 0.2;
345 if ( $delay > 0.6 ) {
346 $delay = 0.0;
347 }
348 $i ++;
349 endwhile;
350 unset( $delay );
351 unset( $i );
352 wp_reset_postdata();
353 ?>
354 </div>
355 </div>
356 <?php
357 }
358 }