PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.3
Forumax – AI Powered Advanced Community Forum Plugin v1.2.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 / Elementor / Forum_Ajax.php

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

337 lines 9.6 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 $this->end_controls_section();
76
77 /**
78 * Styling section starts
79 */
80 $this->start_controls_section(
81 'styling_sec', [
82 'label' => esc_html__( 'Title Style', 'bbp-core' ),
83 'tab' => Controls_Manager::TAB_STYLE,
84 ]
85 );
86 //forum title
87 $this->add_control(
88 'forum_heading',
89 [
90 'label' => esc_html__( 'Forum Title', 'bbp-core' ),
91 'type' => \Elementor\Controls_Manager::HEADING,
92 'separator' => 'before',
93 ]
94 );
95
96
97 $this->add_control(
98 'forum_title_color',
99 [
100 'label' => esc_html__( 'Color', 'bbp-core' ),
101 'type' => \Elementor\Controls_Manager::COLOR,
102 'selectors' => [
103 '{{WRAPPER}} .single-forum-post-widget .post-title a' => 'color: {{VALUE}}',
104 ],
105 ]
106 );
107
108 $this->add_control(
109 'forum_title_hover_color',
110 [
111 'label' => esc_html__( 'Hover Color', 'bbp-core' ),
112 'type' => \Elementor\Controls_Manager::COLOR,
113 'selectors' => [
114 '{{WRAPPER}} .single-forum-post-widget .post-title a:hover' => 'color: {{VALUE}}',
115 ],
116 ]
117 );
118
119 $this->add_group_control(
120 \Elementor\Group_Control_Typography::get_type(),
121 [
122 'name' => 'forum_title_typography',
123 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-title a',
124 ]
125 );
126
127 // Forum meta
128 $this->add_control(
129 'forum_meta',
130 [
131 'label' => esc_html__( 'Forum Meta', 'bbp-core' ),
132 'type' => \Elementor\Controls_Manager::HEADING,
133 'separator' => 'before',
134 ]
135 );
136
137 $this->add_control(
138 'forum_meta_color',
139 [
140 'label' => esc_html__( 'Color', 'bbp-core' ),
141 'type' => \Elementor\Controls_Manager::COLOR,
142 'selectors' => [
143 '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time' => 'color: {{VALUE}}',
144 ],
145 ]
146 );
147
148
149 $this->add_group_control(
150 \Elementor\Group_Control_Typography::get_type(),
151 [
152 'name' => 'forum_meta_typography',
153 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time',
154 ]
155 );
156
157 //parent forum
158 $this->add_control(
159 'parent_forum',
160 [
161 'label' => esc_html__( 'Parent Forum', 'bbp-core' ),
162 'type' => \Elementor\Controls_Manager::HEADING,
163 'separator' => 'before',
164 ]
165 );
166
167 $this->add_control(
168 'parent_forum_color',
169 [
170 'label' => esc_html__( 'Color', 'bbp-core' ),
171 'type' => \Elementor\Controls_Manager::COLOR,
172 'selectors' => [
173 '{{WRAPPER}} .post-content .post-category a' => 'color: {{VALUE}}',
174 ],
175 ]
176 );
177
178 $this->add_control(
179 'parent_forum_color_hover',
180 [
181 'label' => esc_html__( 'Hover color', 'bbp-core' ),
182 'type' => \Elementor\Controls_Manager::COLOR,
183 'selectors' => [
184 '{{WRAPPER}} .post-content .post-category a:hover' => 'color: {{VALUE}}',
185 ],
186 ]
187 );
188
189 $this->add_group_control(
190 \Elementor\Group_Control_Typography::get_type(),
191 [
192 'name' => 'parent_forum_typo',
193 'selector' => '{{WRAPPER}} .post-content .post-category a',
194 ]
195 );
196
197 $this->end_controls_section();
198 }
199
200 protected function render() {
201 $settings = $this->get_settings();
202
203 $topics = new WP_Query( array(
204 'post_type' => 'topic',
205 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9,
206 'order' => $settings['order'] ? $settings['order'] : 'DESC',
207 ) );
208 ?>
209
210 <div class="forum-post-widget" data_id="<?php echo esc_attr( $this->get_id() ); ?>">
211 <div class="post-filter-widget mb-20 wow fadeInUp">
212 <div class="single-filter-item">
213 <a href="#" id="all_filt" data-forum="all" class="data-active">
214 <i class="icon_grid-2x2"></i><?php _e( 'All', 'bbp-core' ) ?>
215 </a>
216 </div>
217 <div class="single-filter-item">
218 <a href="#" id="populer_filt" data-forum="popular">
219 <i class="icon_easel"></i><?php _e( 'Popular', 'bbp-core' ) ?>
220 </a>
221 </div>
222 <div class="single-filter-item">
223 <a href="#" id="featured_filt" data-forum="featured">
224 <i class="icon_ribbon_alt"></i><?php _e( 'Featured', 'bbp-core' ) ?>
225 </a>
226 </div>
227 <div class="single-filter-item">
228 <a href="#" id="recent_filt" data-forum="recent">
229 <i class="icon_clock_alt"></i><?php _e( 'Recent', 'bbp-core' ) ?>
230 </a>
231 </div>
232 <div class="single-filter-item">
233 <a href="#" id="unsolved_filt" data-forum="unsolved">
234 <i class="icon_close_alt2"></i><?php _e( 'Unsolved', 'bbp-core' ) ?>
235 </a>
236 </div>
237 <div class="single-filter-item">
238 <a href="#" id="solved_filt" data-forum="solved">
239 <i class="icon_check_alt2"></i><?php _e( 'Solved', 'bbp-core' ) ?>
240 </a>
241 </div>
242 </div>
243
244 <div id="aj-post-filter-widget">
245 <?php
246 $delay = 0.0;
247 $i = 0;
248 while ( $topics->have_posts() ) : $topics->the_post();
249 $item_id = get_the_ID();
250 $author_id = get_post_field( 'post_author', $item_id );
251 $topic_id = $topics->posts[ $i ]->ID;
252 $vote_count = get_post_meta( $topic_id, "bbpv-votes", true );
253 $forum_id = bbp_get_topic_forum_id();
254 ?>
255 <div class="single-forum-post-widget wow fadeInUp" data-wow-delay="<?php echo $delay ?>s">
256 <div class="post-content">
257 <div class="post-title">
258 <h6><a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a></h6>
259 </div>
260 <div class="post-info">
261 <div class="author">
262 <img src="<?php echo BBPC_IMG ?>/forum_tab/user-circle-alt.svg" alt="<?php esc_attr_e( 'User circle alt icon', 'bbpc-core' ); ?>">
263 <?php
264 echo bbp_get_topic_author_link(
265 array(
266 'post_id' => $topic_id,
267 'type' => 'name'
268 )
269 );
270 ?>
271 </div>
272
273 <div class="post-time">
274 <img src="<?php echo BBPC_IMG ?>/forum_tab/time-outline.svg" alt="<?php esc_attr_e( 'Time outline icon', 'bbpc-core' ); ?>">
275 <?php echo bbp_forum_last_active_time( get_the_ID() ); ?>
276 </div>
277 </div>
278
279 <div class="post-category">
280 <a href="<?php echo get_the_permalink( $forum_id ) ?>">
281 <?php echo get_the_post_thumbnail( $forum_id ); ?>
282 <?php echo bbp_get_topic_forum_title(); ?>
283 </a>
284 </div>
285 </div>
286 <div class="post-reach">
287 <div class="post-view">
288 <img src="<?php echo BBPC_IMG ?>/forum_tab/eye-outline.svg" alt="<?php esc_attr_e( 'Eye outline icon', 'bbpc-core' ); ?>">
289
290 <?php
291 bbp_topic_view_count( $topic_id );
292 echo '&nbsp;';
293 _e( 'Views', 'bbp-core' );
294 ?>
295 </div>
296 <div class="post-like">
297 <img src="<?php echo BBPC_IMG ?>/forum_tab/thumbs-up-outline.svg" alt="<?php esc_attr_e( 'Thumbs-up outline icon', 'bbpc-core' ); ?>">
298
299 <?php
300 if ( $vote_count ) {
301 echo $vote_count;
302 } else {
303 echo "0";
304 }
305
306 echo '&nbsp;';
307 _e( 'Likes', 'bbp-core' );
308 ?>
309 </div>
310 <div class="post-comment">
311 <img src="<?php echo BBPC_IMG ?>/forum_tab/chatbubbles-outline.svg" alt="<?php esc_attr_e( 'Chat bubbles icon', 'bbpc-core' ); ?>">
312
313 <?php
314 bbp_topic_reply_count( $topic_id );
315 echo '&nbsp;';
316 _e( 'Replies', 'bbp-core' );
317 ?>
318 </div>
319 </div>
320 </div>
321
322 <?php
323 $delay += 0.2;
324 if ( $delay > 0.6 ) {
325 $delay = 0.0;
326 }
327 $i ++;
328 endwhile;
329 unset( $delay );
330 unset( $i );
331 wp_reset_postdata();
332 ?>
333 </div>
334 </div>
335 <?php
336 }
337 }