PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / trunk
Forumax – AI Powered Advanced Community Forum Plugin vtrunk
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_Tab.php

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

299 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace admin\Elementor;
3
4 use Elementor\Controls_Manager;
5 use Elementor\Widget_Base;
6 use WP_Query;
7
8 // Exit if accessed directly
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class Forum_Tab extends Widget_Base {
14 public function get_name() {
15 return 'ama_forum_tab';
16 }
17
18 public function get_title() {
19 return esc_html__( 'Forum Tabs (Forumax)', 'forumax' );
20 }
21
22 public function get_icon() {
23 return 'bbpc_icon_ama_forum_tab eicon-tabs';
24 }
25
26 public function get_categories() {
27 return [ 'forumax' ];
28 }
29
30 public function get_style_depends() {
31 return['bbpc-el-widgets'];
32 }
33
34 // scripts dependencies
35 public function get_script_depends() {
36 return [ 'bbpc_js' ];
37 }
38
39
40 protected function register_controls(): void
41 {
42
43
44 //======================= Forum Filter Options ==================
45 $this->start_controls_section(
46 'forum_filter', [
47 'label' => __( 'Forum Filter Options', 'forumax' ),
48 ]
49 );
50
51 $this->add_control(
52 'forum_tab_title', [
53 'label' => __( 'Forum Tab Title', 'forumax' ),
54 'type' => \Elementor\Controls_Manager::TEXT,
55 'default' => __( 'Show Forums', 'forumax' ),
56 'placeholder' => __( 'Enter the tab title', 'forumax' ),
57 ]
58 );
59
60 $this->add_control(
61 'ppp', [
62 'label' => esc_html__( 'Show Forums', 'forumax' ),
63 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'forumax' ),
64 'default' => 9
65 ]
66 );
67
68 $this->add_control(
69 'order', [
70 'label' => esc_html__( 'Order', 'forumax' ),
71 'type' => Controls_Manager::SELECT,
72 'options' => [
73 'ASC' => 'ASC',
74 'DESC' => 'DESC'
75 ],
76 'default' => 'ASC'
77 ]
78 );
79
80 //==== View More Button
81 $this->add_control(
82 'more_txt_heading', [
83 'label' => esc_html__( 'View More Button', 'forumax' ),
84 'type' => Controls_Manager::HEADING,
85 'separator' => 'before',
86 ]
87 );
88
89 $this->add_control(
90 'is_forum_tab_btn', [
91 'label' => esc_html__( 'Button (Show/Hide)', 'forumax' ),
92 'type' => \Elementor\Controls_Manager::SWITCHER,
93 'label_on' => esc_html__( 'Show', 'forumax' ),
94 'label_off' => esc_html__( 'Hide', 'forumax' ),
95 'return_value' => 'yes',
96 'default' => 'yes',
97 ]
98 );
99
100 $this->add_control(
101 'more_txt', [
102 'label' => esc_html__( 'Button Label', 'forumax' ),
103 'type' => Controls_Manager::TEXT,
104 'label_block' => true,
105 'default' => esc_html__('View More', 'forumax'),
106 'condition' => [
107 'is_forum_tab_btn' => 'yes'
108 ]
109 ]
110 );
111
112 $this->add_control(
113 'more_url', [
114 'label' => esc_html__( 'Button URL', 'forumax' ),
115 'type' => \Elementor\Controls_Manager::URL,
116 'default' => [
117 'url' => '#',
118 'is_external' => true,
119 'nofollow' => true,
120 ],
121 'condition' => [
122 'is_forum_tab_btn' => 'yes'
123 ]
124 ]
125 ); //End View More Button
126
127 $this->end_controls_section(); // End Forum Filter Options
128
129
130 //======================== Topic Filter Options =========================//
131 $this->start_controls_section(
132 'topic_filter', [
133 'label' => __( 'Topic Filter Options', 'forumax' ),
134 ]
135 );
136
137 $this->add_control(
138 'topics_tab_title', [
139 'label' => __( 'Topics Tab Title', 'forumax' ),
140 'type' => \Elementor\Controls_Manager::TEXT,
141 'default' => __( 'Show Topics', 'forumax' ),
142 'placeholder' => __( 'Enter the tab title', 'forumax' ),
143 ]
144 );
145
146 $this->add_control(
147 'ppp2', [
148 'label' => esc_html__( 'Show Forums', 'forumax' ),
149 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'forumax' ),
150 'label_block' => true,
151 'default' => 6
152 ]
153 );
154
155 $this->add_control(
156 'order2', [
157 'label' => esc_html__( 'Order', 'forumax' ),
158 'type' => Controls_Manager::SELECT,
159 'options' => [
160 'ASC' => 'ASC',
161 'DESC' => 'DESC'
162 ],
163 'default' => 'ASC'
164 ]
165 );
166
167 //==== View More Button
168 $this->add_control(
169 'more_txt2_heading', [
170 'label' => esc_html__( 'View More Button', 'forumax' ),
171 'type' => Controls_Manager::HEADING,
172 'separator' => 'before',
173 ]
174 );
175
176 $this->add_control(
177 'is_topic_tab_btn', [
178 'label' => esc_html__( 'Button (Show/Hide)', 'forumax' ),
179 'type' => \Elementor\Controls_Manager::SWITCHER,
180 'label_on' => esc_html__( 'Show', 'forumax' ),
181 'label_off' => esc_html__( 'Hide', 'forumax' ),
182 'return_value' => 'yes',
183 'default' => 'yes',
184 ]
185 );
186
187
188 $this->add_control(
189 'more_txt2', [
190 'label' => esc_html__( 'Button Label', 'forumax' ),
191 'type' => Controls_Manager::TEXT,
192 'label_block' => true,
193 'default' => esc_html__('View More', 'forumax'),
194 'condition' => [
195 'is_topic_tab_btn' => 'yes'
196 ]
197 ]
198 );
199
200 $this->add_control(
201 'more_url2', [
202 'label' => esc_html__( 'Button URL', 'forumax' ),
203 'type' => \Elementor\Controls_Manager::URL,
204 'default' => [
205 'url' => '#',
206 'is_external' => true,
207 'nofollow' => true,
208 ],
209 'condition' => [
210 'is_topic_tab_btn' => 'yes'
211 ]
212 ]
213 );
214
215 $this->end_controls_section(); //End Topic Filter Options
216
217
218 //===================== Forum Tab Title ======================//
219 $this->start_controls_section(
220 'forum_tab_style', [
221 'label' => __( 'Forum Tab Title', 'forumax' ),
222 'tab' => Controls_Manager::TAB_STYLE,
223 ]
224 );
225
226
227 $this->add_group_control(
228 \Elementor\Group_Control_Typography::get_type(),
229 [
230 'name' => 'forum_tab_title',
231 'label' => __( 'Tab Label Typography', 'forumax' ),
232 'selector' => '{{WRAPPER}} .community-area .nav-tabs .nav-item button',
233 ]
234 );
235
236 $this->add_control(
237 'forum_tab_title_color',
238 [
239 'label' => __( 'Tab Label Color', 'forumax' ),
240 'type' => \Elementor\Controls_Manager::COLOR,
241 'selectors' => [
242 '{{WRAPPER}} .community-area .nav-tabs .nav-item button' => 'color: {{VALUE}}',
243 ],
244 ]
245 );
246
247 $this->end_controls_section();
248
249
250 $this->start_controls_section(
251 'forum_tab_button', [
252 'label' => esc_html__( 'Forum Tab Button', 'forumax' ),
253 'tab' => Controls_Manager::TAB_STYLE,
254 ]
255 );
256
257 $this->add_responsive_control(
258 'tab_btn_margin', [
259 'label' => esc_html__( 'Margin', 'forumax' ),
260 'type' => Controls_Manager::DIMENSIONS,
261 'size_units' => [ 'px', '%', 'em' ],
262 'selectors' => [
263 '{{WRAPPER}} .tab-content .show-more-btn.show-more-round' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
264 ],
265 ]
266 );
267
268 $this->add_responsive_control(
269 'tab_btn_padding', [
270 'label' => esc_html__( 'Tab button padding', 'forumax' ),
271 'type' => Controls_Manager::DIMENSIONS,
272 'size_units' => [ 'px', '%', 'em' ],
273 'selectors' => [
274 '{{WRAPPER}} .tab-content .show-more-btn.show-more-round' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
275 ],
276 ]
277 );
278
279 $this->end_controls_section();
280 }
281
282 protected function render() {
283 $settings = $this->get_settings();
284
285 $forums = new WP_Query( array(
286 'post_type' => 'forum',
287 'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 9,
288 'order' => $settings['order'],
289 ) );
290
291 $topics = new WP_Query( array(
292 'post_type' => 'topic',
293 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9,
294 'order' => $settings['order'],
295 ) );
296
297 include( "inc/forum/forum_tab.php" );
298 }
299 }