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