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 / Forum_Tab.php

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

250 lines 6.2 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__( 'BBPC Forum Tabs', 'bbp-core' );
20 }
21
22 public function get_icon() {
23 return 'bbpc_icon_ama_forum_tab';
24 }
25
26 public function get_categories() {
27 return [ 'bbp-core' ];
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 [ '' ];
37 }
38
39
40 protected function register_controls() {
41 // --- Forum Filter Options
42 $this->start_controls_section(
43 'forum_filter', [
44 'label' => __( 'Forum Filter Options', 'bbp-core' ),
45 ]
46 );
47
48 $this->add_control(
49 'forum_tab_title',
50 [
51 'label' => __( 'Forum Tab Title', 'bbp-core' ),
52 'type' => \Elementor\Controls_Manager::TEXT,
53 'default' => __( 'Show Forums', 'bbp-core' ),
54 'placeholder' => __( 'Enter the tab title', 'bbp-core' ),
55 ]
56 );
57
58 $this->add_control(
59 'ppp', [
60 'label' => esc_html__( 'Show Forums', 'bbp-core' ),
61 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'bbp-core' ),
62 'default' => 9
63 ]
64 );
65
66 $this->add_control(
67 'order', [
68 'label' => esc_html__( 'Order', 'bbp-core' ),
69 'type' => Controls_Manager::SELECT,
70 'options' => [
71 'ASC' => 'ASC',
72 'DESC' => 'DESC'
73 ],
74 'default' => 'ASC'
75 ]
76 );
77
78 $this->add_control(
79 'more_txt', [
80 'label' => esc_html__( 'More button text', 'bbp-core' ),
81 'type' => Controls_Manager::TEXT,
82 'label_block' => true,
83 'separator' => 'before',
84 'default' => 'Show more'
85 ]
86 );
87
88 $this->add_control(
89 'more_url',
90 [
91 'label' => esc_html__( 'More button link', 'bbp-core' ),
92 'type' => \Elementor\Controls_Manager::URL,
93 'placeholder' => __( 'https://your-link.com', 'bbp-core' ),
94 'default' => [
95 'url' => get_post_type_archive_link( 'forum' ),
96 'is_external' => true,
97 'nofollow' => true,
98 ],
99 ]
100 );
101
102
103 $this->end_controls_section();
104
105 //-------- Topic Filter Options
106 $this->start_controls_section(
107 'topic_filter', [
108 'label' => __( 'Topic Filter Options', 'bbp-core' ),
109 ]
110 );
111
112 $this->add_control(
113 'topics_tab_title',
114 [
115 'label' => __( 'Topics Tab Title', 'bbp-core' ),
116 'type' => \Elementor\Controls_Manager::TEXT,
117 'default' => __( 'Show Topics', 'bbp-core' ),
118 'placeholder' => __( 'Enter the tab title', 'bbp-core' ),
119 ]
120 );
121
122 $this->add_control(
123 'ppp2', [
124 'label' => esc_html__( 'Show Forums', 'bbp-core' ),
125 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'bbp-core' ),
126 'label_block' => true,
127 'default' => 6
128 ]
129 );
130
131 $this->add_control(
132 'order2', [
133 'label' => esc_html__( 'Order', 'bbp-core' ),
134 'type' => Controls_Manager::SELECT,
135 'options' => [
136 'ASC' => 'ASC',
137 'DESC' => 'DESC'
138 ],
139 'default' => 'ASC'
140 ]
141 );
142
143 $this->add_control(
144 'more_txt2', [
145 'label' => esc_html__( 'More button text', 'bbp-core' ),
146 'type' => Controls_Manager::TEXT,
147 'label_block' => true,
148 'default' => 'Show more'
149 ]
150 );
151
152 $this->add_control(
153 'more_url2', [
154 'label' => esc_html__( 'More button link', 'bbp-core' ),
155 'type' => \Elementor\Controls_Manager::URL,
156 'placeholder' => __( 'https://your-link.com', 'bbp-core' ),
157 'default' => [
158 'url' => get_post_type_archive_link( 'topic' ),
159 'is_external' => true,
160 'nofollow' => true,
161 ],
162 ]
163 );
164
165 $this->end_controls_section();
166
167 $this->start_controls_section(
168 'forum_tab_style', [
169 'label' => __( 'Forum Tab Title', 'bbp-core' ),
170 'tab' => Controls_Manager::TAB_STYLE,
171 ]
172 );
173
174 $this->add_group_control(
175 \Elementor\Group_Control_Typography::get_type(),
176 [
177 'name' => 'forum_tab_title',
178 'label' => __( 'Tab Label Typography', 'bbp-core' ),
179 'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
180 'selector' => '{{WRAPPER}} .community-area .nav-tabs .nav-item button',
181 ]
182 );
183
184 $this->add_control(
185 'forum_tab_title_color',
186 [
187 'label' => __( 'Tab Label Color', 'bbp-core' ),
188 'type' => \Elementor\Controls_Manager::COLOR,
189 'scheme' => [
190 'type' => \Elementor\Core\Schemes\Color::get_type(),
191 'value' => \Elementor\Core\Schemes\Color::COLOR_1,
192 ],
193 'selectors' => [
194 '{{WRAPPER}} .community-area .nav-tabs .nav-item button' => 'color: {{VALUE}}',
195 ],
196 ]
197 );
198
199 $this->end_controls_section();
200
201 $this->start_controls_section(
202 'forum_tab_button', [
203 'label' => esc_html__( 'Forum Tab Button', 'bbp-core' ),
204 'tab' => Controls_Manager::TAB_STYLE,
205 ]
206 );
207
208 $this->add_responsive_control(
209 'tab_btn_margin', [
210 'label' => esc_html__( 'Margin', 'bbp-core' ),
211 'type' => Controls_Manager::DIMENSIONS,
212 'size_units' => [ 'px', '%', 'em' ],
213 'selectors' => [
214 '{{WRAPPER}} .tab-content .show-more-btn.show-more-round' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
215 ],
216 ]
217 );
218
219 $this->add_responsive_control(
220 'tab_btn_padding', [
221 'label' => esc_html__( 'Tab button padding', 'bbp-core' ),
222 'type' => Controls_Manager::DIMENSIONS,
223 'size_units' => [ 'px', '%', 'em' ],
224 'selectors' => [
225 '{{WRAPPER}} .tab-content .show-more-btn.show-more-round' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
226 ],
227 ]
228 );
229
230 $this->end_controls_section();
231 }
232
233 protected function render() {
234 $settings = $this->get_settings();
235
236 $forums = new WP_Query( array(
237 'post_type' => 'forum',
238 'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 9,
239 'order' => $settings['order'],
240 ) );
241
242 $topics = new WP_Query( array(
243 'post_type' => 'topic',
244 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9,
245 'order' => $settings['order'],
246 ) );
247
248 include( "inc/forum/forum_tab.php" );
249 }
250 }