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