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

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

252 lines 7.7 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\Core\Schemes\Color;
7 use Elementor\Core\Schemes\Typography;
8 use Elementor\Group_Control_Border;
9 use Elementor\Group_Control_Typography;
10 use Elementor\Widget_Base;
11 use WP_Query;
12
13 // Exit if accessed directly
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 class Single_forum extends Widget_Base
19 {
20
21 public function get_name ()
22 {
23 return 'ama_single_forum';
24 }
25
26 public function get_title ()
27 {
28 return __('BBPC Single Forum', 'bbp-core');
29 }
30
31 public function get_icon ()
32 {
33 return 'bbpc_icon_ama_single_forum';
34 }
35
36 public function get_categories ()
37 {
38 return [ 'bbp-core' ];
39 }
40
41 public function get_style_depends ()
42 {
43 return [ 'bbpc-el-widgets' ];
44 }
45
46 protected function register_controls ()
47 {
48
49 //-------- Select Style ---------- //
50 $this->start_controls_section(
51 'style_sec',
52 [
53 'label' => esc_html__('Preset Skins', 'bbp-core'),
54 ]
55 );
56
57 $this->add_control(
58 'forum_id', [
59 'label' => esc_html__('Select Forum', 'bbp-core'),
60 'type' => Controls_Manager::SELECT,
61 'options' => bbp_core_get_posts('forum')
62 ]
63 );
64
65 $this->add_control(
66 'style',
67 [
68 'label' => esc_html__('Forums Style', 'bbp-core'),
69 'type' => Controls_Manager::CHOOSE,
70 'options' => [
71 '1' => [
72 'icon' => 'single_forum_1',
73 'title' => esc_html__('01 : Single Forum With Topics', 'bbp-core'),
74 ],
75 '2' => [
76 'icon' => 'single_forum_2',
77 'title' => esc_html__('02 : Single Forum', 'bbp-core'),
78 ],
79 ],
80 'default' => '1',
81 'toggle' => false,
82 ]
83 );
84
85 $this->end_controls_section(); // End Style
86
87
88 $this->start_controls_section(
89 'forum_thumb', [
90 'label' => __('Thumbnail', 'bbp-core'),
91 ]
92 );
93
94 $this->add_control(
95 'cover_image', [
96 'label' => __('Custom Cover Image', 'bbp-core'),
97 'type' => Controls_Manager::MEDIA,
98 'description' => __('If this is not set, the featured image will be used by default', 'bbp-core')
99 ]
100 );
101
102 $this->end_controls_section();
103
104 // --- Filter Options
105 $this->start_controls_section(
106 'filter_opt', [
107 'label' => __('Filter Options', 'bbp-core'),
108 ]
109 );
110
111 $this->add_control(
112 'ppp', [
113 'label' => esc_html__('Topics', 'bbp-core'),
114 'description' => esc_html__('Maximum number of topics.', 'bbp-core'),
115 'type' => Controls_Manager::NUMBER,
116 'default' => 3
117 ]
118 );
119
120 $this->add_control(
121 'order', [
122 'label' => esc_html__('Order', 'bbp-core'),
123 'type' => Controls_Manager::SELECT,
124 'options' => [
125 'ASC' => 'ASC',
126 'DESC' => 'DESC'
127 ],
128 'default' => 'ASC'
129 ]
130 );
131
132 $this->add_control(
133 'word_length',
134 [
135 'label' => __('Number of Words', 'bbp-core'),
136 'type' => Controls_Manager::NUMBER,
137 'description' => __('Number of words to show as forum content', 'bbp-core'),
138 'default' => 12
139 ]
140 );
141
142 $this->add_control(
143 'read_more',
144 [
145 'label' => esc_html__('Read More Text', 'bbp-core'),
146 'type' => Controls_Manager::TEXT,
147 'label_block' => true,
148 'default' => __('View All', 'bbp-core'),
149 ]
150 );
151
152 $this->end_controls_section();
153
154 /**============== Background shape Image =====================**/
155 $this->start_controls_section(
156 'single_forum_style', [
157 'label' => __('Single Forum Style', 'bbp-core'),
158 'tab' => Controls_Manager::TAB_STYLE,
159 ]
160 );
161
162 $this->add_group_control(
163 Group_Control_Border::get_type(),
164 [
165 'name' => 'border',
166 'selector' => '{{WRAPPER}} .forum-card, {{WRAPPER}} .forum-with-topics .topic-table .topic-heading, {{WRAPPER}} .forum-with-topics .topic-table .topic-contents',
167 ]
168 );
169
170 $this->add_group_control(
171 Group_Control_Typography::get_type(),
172 [
173 'name' => 'title_typography',
174 'label' => __('Title Typography', 'bbp-core'),
175 'scheme' => Typography::TYPOGRAPHY_1,
176 'separator' => 'before',
177 'selector' => '{{WRAPPER}} .forum-with-topics .topic-table .topic-contents .title h3, {{WRAPPER}} .forum-card .card-title h3',
178 ]
179 );
180
181 $this->add_control(
182 'title_color',
183 [
184 'label' => __('Title Color', 'bbp-core'),
185 'type' => Controls_Manager::COLOR,
186 'scheme' => [
187 'type' => Color::get_type(),
188 'value' => Color::COLOR_1,
189 ],
190 'separator' => 'after',
191 'selectors' => [
192 '{{WRAPPER}} .forum-with-topics .topic-table .topic-contents .title h3' => 'color: {{VALUE}}',
193 '{{WRAPPER}} .forum-card .card-title h3' => 'color: {{VALUE}}'
194 ],
195 ]
196 );
197
198 $this->add_group_control(
199 Group_Control_Typography::get_type(),
200 [
201 'name' => 'excerpt_typography',
202 'label' => __('Excerpt Typography', 'bbp-core'),
203 'scheme' => Typography::TYPOGRAPHY_1,
204 'selector' => '{{WRAPPER}} .forum-with-topics .topic-table .topic-contents .title p, {{WRAPPER}} .forum-card .card-body',
205 ]
206 );
207
208 $this->add_control(
209 'excerpt_color',
210 [
211 'label' => __('Excerpt Color', 'bbp-core'),
212 'type' => Controls_Manager::COLOR,
213 'scheme' => [
214 'type' => Color::get_type(),
215 'value' => Color::COLOR_1,
216 ],
217 'selectors' => [
218 '{{WRAPPER}} .forum-with-topics .topic-table .topic-contents .title p' => 'color: {{VALUE}}',
219 '{{WRAPPER}} .forum-card .card-body' => 'color: {{VALUE}}'
220 ],
221 ]
222 );
223
224 $this->end_controls_section();
225 }
226
227 protected function render ()
228 {
229 $settings = $this->get_settings();
230 $forum_id = $settings[ 'forum_id' ] ? $settings[ 'forum_id' ] : '';
231 $cover_image = $settings[ 'cover_image' ];
232 $post_thumbnail_url = !empty($cover_image[ 'url' ]) ? $cover_image[ 'url' ] : get_the_post_thumbnail_url($forum_id);
233
234 $topics = new WP_Query(array(
235 'post_type' => bbp_get_topic_post_type(),
236 'order' => $settings[ 'order' ] ? $settings[ 'order' ] : 'DESC',
237 'posts_per_page' => $settings[ 'ppp' ] ? $settings[ 'ppp' ] : 3,
238 'post_parent' => $forum_id,
239 ));
240 // echo $settings['style'];
241
242 if ($forum_id) {
243 include "inc/single-forum/single-forum-{$settings['style']}.php";
244 } else {
245 ?>
246 <div class="alert alert-warning" role="alert">
247 <?php _e('Please select a forum.', 'bbp-core'); ?>
248 </div>
249 <?php
250 }
251 }
252 }