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

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