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