PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.0.7
Easy Elements for Elementor – Addons & Website Templates v1.0.7
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
← All changes | widgets/post-comments/post-comments.php +92 -308 1.3.01.0.7 View file →
@@ -1,6 +1,5 @@
1 1 <?php
2 -namespace Easyel\EasyElements\Widgets;
3 2 use Elementor\Widget_Base;
4 3 use Elementor\Controls_Manager;
5 4 use Elementor\Group_Control_Typography;
6 5
@@ -7,10 +6,25 @@
7 6 if ( ! defined( 'ABSPATH' ) ) {
8 7 exit;
9 8 }
10 9
11 -class Easyel_Free_Post_Comments_Widget extends \Elementor\Widget_Base {
10 +if( class_exists("Easyel_Post_Comments_Widget")) {
11 + return;
12 +}
12 13
14 +class Easyel_Post_Comments_Widget extends \Elementor\Widget_Base {
15 +
16 + public function get_style_depends() {
17 + $handle = 'eel-post-comments';
18 + $css_path = plugin_dir_path( __FILE__ ) . 'css/post-comments.css';
19 +
20 + if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) {
21 + wp_register_style( $handle, plugins_url( 'css/post-comments.css', __FILE__ ), [], defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : '1.0.0' );
22 + }
23 +
24 + return [ $handle ];
25 + }
26 +
13 27 public function get_name() {
14 28 return 'eel-post-comments';
15 29 }
16 30
@@ -22,9 +36,9 @@
22 36 return 'easyicon easyelIcon-comments';
23 37 }
24 38
25 39 public function get_categories() {
26 - return [ 'easyelements_category' ];
40 + return [ 'easyelements_category_pro' ];
27 41 }
28 42
29 43 public function get_keywords() {
30 44 return [ 'comments', 'posts', 'next', 'prev', 'page', 'blog' ];
@@ -29,17 +43,10 @@
29 43 public function get_keywords() {
30 44 return [ 'comments', 'posts', 'next', 'prev', 'page', 'blog' ];
31 45 }
32 46
33 - public function get_style_depends() {
34 - return [
35 - 'eel-post-comments',
36 - ];
37 - }
38 -
39 -
40 47 protected function register_controls() {
41 - // button style
48 + // Content Tab
42 49 $this->start_controls_section(
43 50 'comments_content',
44 51 [
45 52 'label' => __( 'Comments', 'easy-elements' ),
@@ -58,205 +65,48 @@
58 65 ]
59 66 );
60 67
61 68 $this->add_control(
62 - 'input__color',
63 - [
64 - 'label' => __( 'Color', 'easy-elements' ),
65 - 'type' => Controls_Manager::COLOR,
66 - 'selectors' => [
67 - '{{WRAPPER}} .eel-post-comments-widget .comment-respond, {{WRAPPER}} .eel-post-comments-widget .title-comments, {{WRAPPER}} .eel-post-comments-widget .comment-list *' => 'color: {{VALUE}};',
68 - ],
69 - ]
70 - );
69 + 'button_color',
70 + [
71 + 'label' => esc_html__( 'Button Text Color', 'easy-elements' ),
72 + 'type' => Controls_Manager::COLOR,
73 + 'selectors' => [
74 + '{{WRAPPER}} .comment-respond .form-submit #submit' => 'color: {{VALUE}};',
75 + ],
76 + ]
77 + );
71 78 $this->add_control(
72 - 'input__color_link',
73 - [
74 - 'label' => __( 'Link Color', 'easy-elements' ),
75 - 'type' => Controls_Manager::COLOR,
76 - 'selectors' => [
77 - '{{WRAPPER}} .eel-post-comments-widget .comment-respond a' => 'color: {{VALUE}};',
78 - ],
79 - ]
80 - );
81 -
82 - $this->end_controls_section();
83 -
84 - $this->start_controls_section(
85 - 'form_content_label',
86 - [
87 - 'label' => __( 'Label', 'easy-elements' ),
88 - 'tab' => Controls_Manager::TAB_CONTENT,
89 - ]
90 - );
91 -
79 + 'button_hover_color',
80 + [
81 + 'label' => esc_html__( 'Button Hover Text Color', 'easy-elements' ),
82 + 'type' => Controls_Manager::COLOR,
83 + 'selectors' => [
84 + '{{WRAPPER}} .comment-respond .form-submit #submit:hover' => 'color: {{VALUE}};',
85 + ],
86 + ]
87 + );
92 88 $this->add_control(
93 - 'input_label_color',
94 - [
95 - 'label' => __( 'Color', 'easy-elements' ),
96 - 'type' => Controls_Manager::COLOR,
97 - 'selectors' => [
98 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form label' => 'color: {{VALUE}};',
99 - ],
100 - ]
101 - );
102 -
103 - $this->add_responsive_control(
104 - 'input_label_margin',[
105 - 'label' => __( 'Margin', 'easy-elements' ),
106 - 'type' => Controls_Manager::DIMENSIONS,
107 - 'size_units' => [ 'px', '%', 'em' ],
108 - 'selectors' => [
109 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
110 - ],
111 - ]
112 - );
113 -
114 - // Input Color Picker
115 - $this->add_group_control(
116 - \Elementor\Group_Control_Typography::get_type(),
117 - [
118 - 'name' => 'input_label_typography',
119 - 'label' => __( 'Typography', 'easy-elements' ),
120 - 'selector' => '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form label',
121 - 'description' => __( 'Customize the typography for form field labels', 'easy-elements' ),
122 - ]
123 - );
124 - $this->end_controls_section();
125 -
126 - // form style
127 - $this->start_controls_section(
128 - 'form_content',
129 - [
130 - 'label' => __( 'Input', 'easy-elements' ),
131 - 'tab' => Controls_Manager::TAB_CONTENT,
132 - ]
133 - );
134 -
89 + 'button_bg_color',
90 + [
91 + 'label' => esc_html__( 'Button Background', 'easy-elements' ),
92 + 'type' => Controls_Manager::COLOR,
93 + 'selectors' => [
94 + '{{WRAPPER}} .comment-respond .form-submit #submit' => 'background: {{VALUE}};',
95 + ],
96 + ]
97 + );
135 98 $this->add_control(
136 - 'input_color',
137 - [
138 - 'label' => __( 'Color', 'easy-elements' ),
139 - 'type' => Controls_Manager::COLOR,
140 - 'selectors' => [
141 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form input:not([type="submit"]),
142 - {{WRAPPER}} .eel-post-comments-widget #comments .comment-form textarea'
143 - => 'color: {{VALUE}};',
144 - ],
145 - ]
146 - );
147 -
99 + 'button_bg_hover_color',
100 + [
101 + 'label' => esc_html__( 'Button Hover Background', 'easy-elements' ),
102 + 'type' => Controls_Manager::COLOR,
103 + 'selectors' => [
104 + '{{WRAPPER}} .comment-respond .form-submit #submit:hover' => 'background: {{VALUE}};',
105 + ],
106 + ]
107 + );
148 108 $this->add_group_control(
149 - \Elementor\Group_Control_Background::get_type(),
150 - [
151 - 'name' => 'input_background',
152 - 'label' => __( 'Background', 'easy-elements' ),
153 - 'types' => [ 'classic', 'gradient' ],
154 - 'selector' =>
155 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form input:not([type="submit"]),
156 - {{WRAPPER}} .eel-post-comments-widget #comments .comment-form textarea',
157 - ]
158 - );
159 -
160 - $this->add_control(
161 - 'input_focus_border_color',
162 - [
163 - 'label' => __( 'Focus Border Color', 'easy-elements' ),
164 - 'type' => Controls_Manager::COLOR,
165 - 'selectors' => [
166 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form input:not([type="submit"]):focus,
167 - {{WRAPPER}} .eel-post-comments-widget #comments .comment-form textarea:focus'
168 - => 'border-color: {{VALUE}};',
169 - ],
170 - ]
171 - );
172 -
173 - $this->add_responsive_control(
174 - 'input_form_padding',
175 - [
176 - 'label' => __( 'Padding', 'easy-elements' ),
177 - 'type' => Controls_Manager::DIMENSIONS,
178 - 'size_units' => [ 'px', '%', 'em' ],
179 - 'selectors' => [
180 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form input:not([type="submit"]),
181 - {{WRAPPER}} .eel-post-comments-widget #comments .comment-form textarea'
182 - => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
183 - ],
184 - ]
185 - );
186 -
187 - /* ================= Border Radius ================= */
188 - $this->add_responsive_control(
189 - 'input_border_radius',
190 - [
191 - 'label' => __( 'Border Radius', 'easy-elements' ),
192 - 'type' => Controls_Manager::DIMENSIONS,
193 - 'size_units' => [ 'px', '%', 'em' ],
194 - 'selectors' => [
195 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form input:not([type="submit"]),
196 - {{WRAPPER}} .eel-post-comments-widget #comments .comment-form textarea'
197 - => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
198 - ],
199 - ]
200 - );
201 -
202 - /* ================= Border ================= */
203 - $this->add_group_control(
204 - \Elementor\Group_Control_Border::get_type(),
205 - [
206 - 'name' => 'input_border',
207 - 'selector' =>
208 - '{{WRAPPER}} .eel-post-comments-widget #comments .comment-form input:not([type="submit"]),
209 - {{WRAPPER}} .eel-post-comments-widget #comments .comment-form textarea',
210 - ]
211 - );
212 -
213 - $this->end_controls_section();
214 -
215 -
216 - $this->start_controls_section(
217 - 'comments_content_button_style',
218 - [
219 - 'label' => __( 'Button', 'easy-elements' ),
220 - 'tab' => Controls_Manager::TAB_CONTENT,
221 - ]
222 - );
223 -
224 - /* Tabs start */
225 - $this->start_controls_tabs( 'button_style_tabs' );
226 -
227 - /* ================= NORMAL TAB ================= */
228 - $this->start_controls_tab(
229 - 'button_normal_tab',
230 - [
231 - 'label' => __( 'Normal', 'easy-elements' ),
232 - ]
233 - );
234 -
235 - $this->add_control(
236 - 'button_color',
237 - [
238 - 'label' => esc_html__( 'Color', 'easy-elements' ),
239 - 'type' => Controls_Manager::COLOR,
240 - 'selectors' => [
241 - '{{WRAPPER}} .comment-respond .form-submit #submit' => 'color: {{VALUE}};',
242 - ],
243 - ]
244 - );
245 -
246 - $this->add_control(
247 - 'button_bg_color',
248 - [
249 - 'label' => esc_html__( 'Background Color', 'easy-elements' ),
250 - 'type' => Controls_Manager::COLOR,
251 - 'selectors' => [
252 - '{{WRAPPER}} .comment-respond .form-submit #submit' => 'background-color: {{VALUE}};',
253 - ],
254 - ]
255 - );
256 -
257 - /* Typography */
258 - $this->add_group_control(
259 109 \Elementor\Group_Control_Typography::get_type(),
260 110 [
261 111 'name' => 'button_typography',
262 112 'selector' => '{{WRAPPER}} .comment-respond .form-submit #submit',
@@ -261,130 +111,64 @@
261 111 'name' => 'button_typography',
262 112 'selector' => '{{WRAPPER}} .comment-respond .form-submit #submit',
263 113 ]
264 114 );
265 -
266 - /* Padding */
267 115 $this->add_responsive_control(
268 - 'button_padding',
269 - [
270 - 'label' => esc_html__( 'Padding', 'easy-elements' ),
271 - 'type' => Controls_Manager::DIMENSIONS,
272 - 'size_units' => [ 'px', 'em', '%' ],
273 - 'selectors' => [
274 - '{{WRAPPER}} .comment-respond .form-submit #submit' =>
275 - 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
276 - ],
277 - ]
278 - );
116 + 'button_padding',
117 + [
118 + 'label' => esc_html__('Padding', 'easy-elements'),
119 + 'type' => \Elementor\Controls_Manager::DIMENSIONS,
120 + 'size_units' => ['px', 'em', '%'],
121 + 'selectors' => [
122 + '{{WRAPPER}} .comment-respond .form-submit #submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
123 + ],
124 + ]
125 + );
279 126
280 - $this->add_group_control(
281 - \Elementor\Group_Control_Border::get_type(),
282 - [
283 - 'name' => 'button_border',
284 - 'selector' => '{{WRAPPER}} .comment-respond .form-submit #submit',
285 - ]
286 - );
287 -
288 - $this->end_controls_tab();
289 -
290 - /* ================= HOVER TAB ================= */
291 - $this->start_controls_tab(
292 - 'button_hover_tab',
293 - [
294 - 'label' => __( 'Hover', 'easy-elements' ),
295 - ]
296 - );
297 -
298 - $this->add_control(
299 - 'button_hover_color',
300 - [
301 - 'label' => esc_html__( 'Color', 'easy-elements' ),
302 - 'type' => Controls_Manager::COLOR,
303 - 'selectors' => [
304 - '{{WRAPPER}} .comment-respond .form-submit #submit:hover' => 'color: {{VALUE}};',
305 - ],
306 - ]
307 - );
308 -
309 - $this->add_control(
310 - 'button_bg_hover_color',
311 - [
312 - 'label' => esc_html__( 'Background Color', 'easy-elements' ),
313 - 'type' => Controls_Manager::COLOR,
314 - 'selectors' => [
315 - '{{WRAPPER}} .comment-respond .form-submit #submit:hover' => 'background-color: {{VALUE}};',
316 - ],
317 - ]
318 - );
319 -
320 - $this->add_group_control(
321 - \Elementor\Group_Control_Border::get_type(),
322 - [
323 - 'name' => 'button_border_hover',
324 - 'selector' => '{{WRAPPER}} .comment-respond .form-submit #submit:hover',
325 - ]
326 - );
327 - $this->end_controls_tab();
328 - $this->end_controls_tabs();
329 - $this->end_controls_section();
330 -
127 + $this->end_controls_section();
331 128 }
332 -
333 129
334 130 protected function render() {
335 131 $settings = $this->get_settings_for_display();
336 132
337 - global $post;
338 - $original_post = $post;
339 -
340 - // Get post object: editor mode uses prepared post, frontend uses current post
133 + // Always show the comment form in Elementor editor mode
341 134 if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
342 - if ( ($settings['show_comments'] ?? 'no') !== 'yes' ) {
343 - // Editor mode: show nothing if 'show_comments' is not 'yes'
344 - echo '<p>' . esc_html__( 'Comments are disabled in editor preview.', 'easy-elements' ) . '</p>';
345 - return;
346 - }
135 + echo '<div class="eel-post-comments-widget">';
347 136
348 - $post_id = function_exists('easyel_get_prepared_post_id')
349 - ? easyel_get_prepared_post_id()
350 - : get_the_ID();
351 - $post_obj = get_post( $post_id );
137 + global $post;
138 + $has_comments_form = false;
352 139
353 - } else {
354 - if ( ($settings['show_comments'] ?? 'no') !== 'yes' ) {
355 - // Frontend: comments disabled in settings
356 - return;
140 + if ( $post && post_type_supports( $post->post_type, 'comments' ) ) {
141 + ob_start();
142 + comments_template();
143 + $output = ob_get_clean();
144 + if ( trim( wp_strip_all_tags( $output ) ) ) {
145 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
146 + echo $output;
147 + $has_comments_form = true;
148 + }
357 149 }
358 150
359 - $post_obj = $post;
360 - if ( ! $post_obj instanceof \WP_Post ) {
361 - echo '<p>' . esc_html__( 'Invalid post object.', 'easy-elements' ) . '</p>';
362 - return;
151 + if ( ! $has_comments_form ) {
152 + // Show only a message for preview
153 + echo '<p>' . esc_html__( 'Comments form will appear here on the frontend.', 'easy-elements' ) . '</p>';
363 154 }
155 +
156 + echo '</div>';
157 + return;
364 158 }
365 159
366 - $post = $post_obj;
367 - setup_postdata( $post );
368 -
369 - echo '<div class="eel-post-comments-widget">';
370 -
371 - if ( post_type_supports( $post->post_type, 'comments' ) ) {
160 + if ( 'yes' === $settings['show_comments'] ) {
372 161 if ( post_password_required() ) {
373 162 echo '<p>' . esc_html__( 'This post is password protected. Enter the password to view comments.', 'easy-elements' ) . '</p>';
374 - } else {
375 - comments_template();
163 + return;
376 164 }
165 +
166 + // Output the comments template
167 + echo '<div class="eel-post-comments-widget">';
168 + comments_template();
169 + echo '</div>';
377 170 } else {
378 - if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
379 - echo '<p>' . esc_html__( 'Comments are not enabled for this post type.', 'easy-elements' ) . '</p>';
380 - }
171 +
381 172 }
382 -
383 - echo '</div>';
384 -
385 - wp_reset_postdata();
386 - $post = $original_post;
387 -
388 173 }
389 -
390 174 }