PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.1.0
Forumax – AI Powered Advanced Community Forum Plugin v1.1.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 2.0.0 2.1.0 All 29 releases
bbp-core / includes / Elementor / Forums.php

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

230 lines 7.0 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\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Core\Schemes\Typography;
8 use Elementor\Core\Schemes\Color;
9 use Elementor\Group_Control_Typography;
10 use Elementor\Group_Control_Text_Shadow;
11 use WP_Query;
12 use WP_Post;
13
14 // Exit if accessed directly
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Class Forums
21 *
22 * @package amaCore\Widgets
23 */
24 class Forums extends Widget_Base {
25
26 public function get_name() {
27 return 'ama_forums';
28 }
29
30 public function get_title() {
31 return __( 'BBPC Forums', 'bbp-core' );
32 }
33
34 public function get_icon() {
35 return 'bbpc_icon_ama_forums';
36 }
37
38 public function get_categories() {
39 return [ 'bbp-core' ];
40 }
41
42 // style dependency
43 public function get_style_depends() {
44 return [ 'bbpc-el-widgets' ];
45 }
46
47 public function get_script_depends() {
48 return [ 'bbpc-ajax' ];
49 }
50
51 protected function register_controls() {
52
53 // --- Filter Options
54 $this->start_controls_section(
55 'filter_opt', [
56 'label' => __( 'Filter Options', 'bbp-core' ),
57 ]
58 );
59
60 $this->add_control(
61 'ppp', [
62 'label' => esc_html__( 'Show Forums', 'bbp-core' ),
63 'description' => esc_html__( 'Show the forums count at the initial view. Default is 5 forums in a row.', 'bbp-core' ),
64 'type' => Controls_Manager::NUMBER,
65 'label_block' => true,
66 'default' => 5
67 ]
68 );
69
70 $this->add_control(
71 'ppp2', [
72 'label' => esc_html__( 'Hidden Forums', 'bbp-core' ),
73 'description' => esc_html__( 'Hidden forums will show on clicking on the More button.', 'bbp-core' ),
74 'type' => Controls_Manager::NUMBER,
75 'label_block' => true,
76 'default' => 10
77 ]
78 );
79
80 $this->add_control(
81 'order', [
82 'label' => esc_html__( 'Order', 'bbp-core' ),
83 'type' => Controls_Manager::SELECT,
84 'options' => [
85 'ASC' => 'ASC',
86 'DESC' => 'DESC'
87 ],
88 'default' => 'ASC'
89 ]
90 );
91
92 $this->add_control(
93 'more_txt', [
94 'label' => esc_html__( 'Read More Text', 'bbp-core' ),
95 'type' => Controls_Manager::TEXT,
96 'label_block' => true,
97 'default' => 'More Communities'
98 ]
99 );
100
101 $this->end_controls_section();
102 // end Document Setting Section
103
104 $this->start_controls_section(
105 'forum_styling', [
106 'label' => esc_html__( 'Forum Style', 'bbp-core' ),
107 'tab' => Controls_Manager::TAB_STYLE,
108 ]
109 );
110
111 $this->add_group_control(
112 \Elementor\Group_Control_Typography::get_type(),
113 [
114 'name' => 'forum_title_typography',
115 'label' => esc_html__( 'Forum Title Typography', 'bbp-core' ),
116 'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
117 'selector' => '{{WRAPPER}} .com-box-content .title a',
118 ]
119 );
120
121
122 $this->add_group_control(
123 \Elementor\Group_Control_Typography::get_type(),
124 [
125 'name' => 'more_text_typography',
126 'label' => esc_html__( 'More text typography', 'bbp-core' ),
127 'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
128 'selector' => '{{WRAPPER}} .collapse-btn',
129
130 ]
131 );
132
133 $this->add_control(
134 'more_text_color',
135 [
136 'label' => esc_html__( 'More text color', 'bbp-core' ),
137 'type' => \Elementor\Controls_Manager::COLOR,
138 'scheme' => [
139 'type' => \Elementor\Core\Schemes\Color::get_type(),
140 'value' => \Elementor\Core\Schemes\Color::COLOR_1,
141 ],
142 'selectors' => [
143 '{{WRAPPER}} .collapse-btn' => 'color: {{VALUE}}',
144 '{{WRAPPER}} .more-communities .collapse-btn svg path' => 'stroke: {{VALUE}}',
145 ],
146 ]
147 );
148
149 $this->end_controls_section();
150 }
151
152 protected function render() {
153 $settings = $this->get_settings();
154 $forums = new WP_Query( array(
155 'post_type' => 'forum',
156 'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 5,
157 'order' => $settings['order'] ? $settings['order'] : 'ASC',
158 ) );
159 ?>
160 <div class="communities-boxes">
161 <?php
162 while ( $forums->have_posts() ) : $forums->the_post();
163 ?>
164 <div class="com-box wow fadeInRight" data-wow-delay="0.5s">
165 <div class="icon-container">
166 <?php the_post_thumbnail( 'full' ); ?>
167 </div>
168 <div class="com-box-content">
169 <h3 class="title">
170 <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a>
171 </h3>
172 <p class="total-post"> <?php bbp_forum_topic_count( get_the_ID() ); ?> <?php esc_html_e( ' Posts', 'bbp-core' ) ?> </p>
173 </div>
174 <!-- /.ama-com-box-content -->
175 </div>
176 <!-- /.ama-com-box -->
177 <?php
178 endwhile;
179 wp_reset_postdata();
180 ?>
181 </div>
182 <!-- /.communities-boxes -->
183
184 <div class="more-communities" data_id="<?php echo esc_attr( $this->get_id() );?>">
185
186 <a href="#more-category" class="collapse-btn-wrap">
187 <?php echo esc_html( $settings['more_txt'] ); ?>
188
189 <svg fill="#000000" width="16px" height="16px" viewBox="0 0 24 24" id="minus" data-name="Line Color" xmlns="http://www.w3.org/2000/svg" class="icon line-color icon_minus"> <line id="primary" x1="19" y1="12" x2="5" y2="12" style="fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;"></line> </svg>
190
191 <svg fill="#000000" width="16px" height="16px" viewBox="0 0 24 24" id="plus" data-name="Line Color" xmlns="http://www.w3.org/2000/svg" class="icon line-color icon_plus"><path id="primary" d="M5,12H19M12,5V19" style="fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;"></path></svg>
192 </a>
193
194 <div class="collapse-wrap" id="more-category" data_id="<?php echo esc_attr( $this->get_id() );?>">
195 <div class="communities-boxes">
196 <?php
197 $forums2 = new WP_Query( array(
198 'post_type' => 'forum',
199 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 10,
200 'offset' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 5,
201 'order' => $settings['order'],
202 ) );
203 while ( $forums2->have_posts() ) : $forums2->the_post();
204 ?>
205 <div class="com-box">
206 <div class="icon-container">
207 <?php the_post_thumbnail( 'full' ); ?>
208 </div>
209 <div class="com-box-content">
210 <h3 class="title">
211 <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a>
212 </h3>
213 <p class="total-post"> <?php bbp_forum_topic_count( get_the_ID() ); ?> <?php esc_html_e( ' Posts', 'bbp-core' ); ?> </p>
214 </div>
215 <!-- /.ama-com-box-content -->
216 </div>
217 <!-- /.ama-com-box -->
218 <?php
219 endwhile;
220 wp_reset_postdata();
221 ?>
222 </div>
223 <!-- /.communities-boxes -->
224 </div>
225 <!-- /.collapse-wrap -->
226 </div>
227 <!-- /.more-communities -->
228 <?php
229 }
230 }