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

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