PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.7
Forumax – AI Powered Advanced Community Forum Plugin v1.2.7
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.2.7, at includes/Elementor/Forum_Tab.php

245 lines 6.3 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 [ 'bbpc_js' ];
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 'selector' => '{{WRAPPER}} .community-area .nav-tabs .nav-item button',
180 ]
181 );
182
183 $this->add_control(
184 'forum_tab_title_color',
185 [
186 'label' => __( 'Tab Label Color', 'bbp-core' ),
187 'type' => \Elementor\Controls_Manager::COLOR,
188 'selectors' => [
189 '{{WRAPPER}} .community-area .nav-tabs .nav-item button' => 'color: {{VALUE}}',
190 ],
191 ]
192 );
193
194 $this->end_controls_section();
195
196 $this->start_controls_section(
197 'forum_tab_button', [
198 'label' => esc_html__( 'Forum Tab Button', 'bbp-core' ),
199 'tab' => Controls_Manager::TAB_STYLE,
200 ]
201 );
202
203 $this->add_responsive_control(
204 'tab_btn_margin', [
205 'label' => esc_html__( 'Margin', 'bbp-core' ),
206 'type' => Controls_Manager::DIMENSIONS,
207 'size_units' => [ 'px', '%', 'em' ],
208 'selectors' => [
209 '{{WRAPPER}} .tab-content .show-more-btn.show-more-round' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
210 ],
211 ]
212 );
213
214 $this->add_responsive_control(
215 'tab_btn_padding', [
216 'label' => esc_html__( 'Tab button padding', 'bbp-core' ),
217 'type' => Controls_Manager::DIMENSIONS,
218 'size_units' => [ 'px', '%', 'em' ],
219 'selectors' => [
220 '{{WRAPPER}} .tab-content .show-more-btn.show-more-round' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
221 ],
222 ]
223 );
224
225 $this->end_controls_section();
226 }
227
228 protected function render() {
229 $settings = $this->get_settings();
230
231 $forums = new WP_Query( array(
232 'post_type' => 'forum',
233 'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 9,
234 'order' => $settings['order'],
235 ) );
236
237 $topics = new WP_Query( array(
238 'post_type' => 'topic',
239 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9,
240 'order' => $settings['order'],
241 ) );
242
243 include( "inc/forum/forum_tab.php" );
244 }
245 }