PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.2.8
Easy Elements for Elementor – Addons & Website Templates v1.2.8
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
easy-elements / widgets / post-content / post-content.php

post-content.php in Easy Elements for Elementor – Addons & Website Templates 1.2.8, at widgets/post-content/post-content.php

588 lines 16.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Widgets;
3 use Elementor\Controls_Manager;
4 use Elementor\Widget_Base;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 class Easyel_Free_Post_content_Widget extends \Elementor\Widget_Base {
11
12 public function get_name() {
13 return 'eel-post-content';
14 }
15
16 public function get_title() {
17 return __( 'Post Content', 'easy-elements' );
18 }
19
20 public function get_icon() {
21 return 'easyicon easyelIcon-post-content';
22 }
23
24 public function get_categories() {
25 return [ 'easyelements_category' ];
26 }
27
28 public function get_keywords() {
29 return [ 'post', 'content', 'link', 'click', 'text' ];
30 }
31
32 public function get_style_depends() {
33 return [
34 'eel-post-content',
35 ];
36 }
37
38
39 protected function register_controls() {
40
41 $this->start_controls_section(
42 'content_section',
43 [
44 'label' => esc_html__('Content Style', 'easy-elements'),
45 'tab' => Controls_Manager::TAB_CONTENT,
46 ]
47 );
48
49 $this->add_control(
50 'content_color',
51 [
52 'label' => esc_html__('Color', 'easy-elements'),
53 'type' => Controls_Manager::COLOR,
54 'selectors' => [
55 '{{WRAPPER}} .eel-post-content' => 'color: {{VALUE}};',
56 ],
57 ]
58 );
59
60 $this->add_group_control(
61 \Elementor\Group_Control_Typography::get_type(),
62 [
63 'name' => 'content_typography',
64 'selector' => '{{WRAPPER}} .eel-post-content',
65 ]
66 );
67
68 $this->add_control(
69 'global_heading',
70 [
71 'label' => esc_html__( 'Global Heading', 'easy-elements' ),
72 'type' => \Elementor\Controls_Manager::HEADING,
73 'separator' => 'after',
74 ]
75 );
76
77 $this->add_control(
78 'global_color',
79 [
80 'label' => esc_html__('Color', 'easy-elements'),
81 'type' => Controls_Manager::COLOR,
82 'selectors' => [
83 '{{WRAPPER}} .eel-post-content h1, {{WRAPPER}} .eel-post-content h2, {{WRAPPER}} .eel-post-content h3, {{WRAPPER}} .eel-post-content h4, {{WRAPPER}} .eel-post-content h5, {{WRAPPER}} .eel-post-content h6' => 'color: {{VALUE}};',
84 ],
85 ]
86 );
87
88 $this->add_group_control(
89 \Elementor\Group_Control_Typography::get_type(),
90 [
91 'name' => 'global_typography',
92 'selector' => '{{WRAPPER}} .eel-post-content h1, {{WRAPPER}} .eel-post-content h2, {{WRAPPER}} .eel-post-content h3, {{WRAPPER}} .eel-post-content h4, {{WRAPPER}} .eel-post-content h5, {{WRAPPER}} .eel-post-content h6',
93 ]
94 );
95
96 $this->add_responsive_control(
97 'global_margin',
98 [
99 'label' => __( 'Margin', 'easy-elements' ),
100 'type' => \Elementor\Controls_Manager::DIMENSIONS,
101 'size_units' => [ 'px', 'em', '%' ],
102 'selectors' => [
103 '{{WRAPPER}} .eel-post-content h1, {{WRAPPER}} .eel-post-content h2, {{WRAPPER}} .eel-post-content h3, {{WRAPPER}} .eel-post-content h4, {{WRAPPER}} .eel-post-content h5, {{WRAPPER}} .eel-post-content h6' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
104 ],
105 ]
106 );
107
108 $this->add_control(
109 'strong_heading',
110 [
111 'label' => esc_html__( 'Strong Style', 'easy-elements' ),
112 'type' => \Elementor\Controls_Manager::HEADING,
113 'separator' => 'after',
114 ]
115 );
116
117 $this->add_control(
118 'strong_color',
119 [
120 'label' => esc_html__('Color', 'easy-elements'),
121 'type' => Controls_Manager::COLOR,
122 'selectors' => [
123 '{{WRAPPER}} .eel-post-content strong' => 'color: {{VALUE}};',
124 ],
125 ]
126 );
127
128 $this->add_group_control(
129 \Elementor\Group_Control_Typography::get_type(),
130 [
131 'name' => 'strong_typography',
132 'selector' => '{{WRAPPER}} .eel-post-content strong',
133 ]
134 );
135
136 $this->add_control(
137 'link_heading',
138 [
139 'label' => esc_html__( 'Link Style', 'easy-elements' ),
140 'type' => \Elementor\Controls_Manager::HEADING,
141 'separator' => 'after',
142 ]
143 );
144
145 $this->add_control(
146 'link_color',
147 [
148 'label' => esc_html__('Color', 'easy-elements'),
149 'type' => Controls_Manager::COLOR,
150 'selectors' => [
151 '{{WRAPPER}} .eel-post-content a' => 'color: {{VALUE}};',
152 ],
153 ]
154 );
155
156 $this->add_group_control(
157 \Elementor\Group_Control_Typography::get_type(),
158 [
159 'name' => 'link_typography',
160 'selector' => '{{WRAPPER}} .eel-post-content a',
161 ]
162 );
163
164 $this->end_controls_section();
165
166 $this->start_controls_section(
167 'content_section_heading',
168 [
169 'label' => esc_html__('Heading Style', 'easy-elements'),
170 'tab' => Controls_Manager::TAB_CONTENT,
171 ]
172 );
173
174 $this->add_control(
175 'h1_heading',
176 [
177 'label' => esc_html__( 'H1 Heading', 'easy-elements' ),
178 'type' => \Elementor\Controls_Manager::HEADING,
179 ]
180 );
181
182 $this->add_control(
183 'h1_color',
184 [
185 'label' => esc_html__('Color', 'easy-elements'),
186 'type' => Controls_Manager::COLOR,
187 'selectors' => [
188 '{{WRAPPER}} .eel-post-content h1' => 'color: {{VALUE}};',
189 ],
190 ]
191 );
192
193 $this->add_group_control(
194 \Elementor\Group_Control_Typography::get_type(),
195 [
196 'name' => 'h1_typography',
197 'selector' => '{{WRAPPER}} .eel-post-content h1',
198 ]
199 );
200
201 $this->add_responsive_control(
202 'h1_margin',
203 [
204 'label' => __( 'Margin', 'easy-elements' ),
205 'type' => \Elementor\Controls_Manager::DIMENSIONS,
206 'size_units' => [ 'px', 'em', '%' ],
207 'selectors' => [
208 '{{WRAPPER}} .eel-post-content h1' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
209 ],
210 ]
211 );
212
213 $this->add_control(
214 'h2_heading',
215 [
216 'label' => esc_html__( 'H2 Heading', 'easy-elements' ),
217 'type' => \Elementor\Controls_Manager::HEADING,
218 ]
219 );
220
221 $this->add_control(
222 'h2_color',
223 [
224 'label' => esc_html__('Color', 'easy-elements'),
225 'type' => Controls_Manager::COLOR,
226 'selectors' => [
227 '{{WRAPPER}} .eel-post-content h2' => 'color: {{VALUE}};',
228 ],
229 ]
230 );
231
232 $this->add_group_control(
233 \Elementor\Group_Control_Typography::get_type(),
234 [
235 'name' => 'h2_typography',
236 'selector' => '{{WRAPPER}} .eel-post-content h2',
237 ]
238 );
239
240 $this->add_responsive_control(
241 'h2_margin',
242 [
243 'label' => __( 'Margin', 'easy-elements' ),
244 'type' => \Elementor\Controls_Manager::DIMENSIONS,
245 'size_units' => [ 'px', 'em', '%' ],
246 'selectors' => [
247 '{{WRAPPER}} .eel-post-content h2' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
248 ],
249 ]
250 );
251
252 $this->add_control(
253 'h3_heading',
254 [
255 'label' => esc_html__( 'H3 Heading', 'easy-elements' ),
256 'type' => \Elementor\Controls_Manager::HEADING,
257 ]
258 );
259
260 $this->add_control(
261 'h3_color',
262 [
263 'label' => esc_html__('Color', 'easy-elements'),
264 'type' => Controls_Manager::COLOR,
265 'selectors' => [
266 '{{WRAPPER}} .eel-post-content h3' => 'color: {{VALUE}};',
267 ],
268 ]
269 );
270
271 $this->add_group_control(
272 \Elementor\Group_Control_Typography::get_type(),
273 [
274 'name' => 'h3_typography',
275 'selector' => '{{WRAPPER}} .eel-post-content h3',
276 ]
277 );
278
279 $this->add_responsive_control(
280 'h3_margin',
281 [
282 'label' => __( 'Margin', 'easy-elements' ),
283 'type' => \Elementor\Controls_Manager::DIMENSIONS,
284 'size_units' => [ 'px', 'em', '%' ],
285 'selectors' => [
286 '{{WRAPPER}} .eel-post-content h3' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
287 ],
288 ]
289 );
290
291 $this->add_control(
292 'h4_heading',
293 [
294 'label' => esc_html__( 'H4 Heading', 'easy-elements' ),
295 'type' => \Elementor\Controls_Manager::HEADING,
296 ]
297 );
298
299 $this->add_control(
300 'h4_color',
301 [
302 'label' => esc_html__('Color', 'easy-elements'),
303 'type' => Controls_Manager::COLOR,
304 'selectors' => [
305 '{{WRAPPER}} .eel-post-content h4' => 'color: {{VALUE}};',
306 ],
307 ]
308 );
309
310 $this->add_group_control(
311 \Elementor\Group_Control_Typography::get_type(),
312 [
313 'name' => 'h4_typography',
314 'selector' => '{{WRAPPER}} .eel-post-content h4',
315 ]
316 );
317
318 $this->add_responsive_control(
319 'h4_margin',
320 [
321 'label' => __( 'Margin', 'easy-elements' ),
322 'type' => \Elementor\Controls_Manager::DIMENSIONS,
323 'size_units' => [ 'px', 'em', '%' ],
324 'selectors' => [
325 '{{WRAPPER}} .eel-post-content h4' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
326 ],
327 ]
328 );
329
330 $this->add_control(
331 'h5_heading',
332 [
333 'label' => esc_html__( 'H5 Heading', 'easy-elements' ),
334 'type' => \Elementor\Controls_Manager::HEADING,
335 ]
336 );
337
338 $this->add_control(
339 'h5_color',
340 [
341 'label' => esc_html__('Color', 'easy-elements'),
342 'type' => Controls_Manager::COLOR,
343 'selectors' => [
344 '{{WRAPPER}} .eel-post-content h5' => 'color: {{VALUE}};',
345 ],
346 ]
347 );
348
349 $this->add_group_control(
350 \Elementor\Group_Control_Typography::get_type(),
351 [
352 'name' => 'h5_typography',
353 'selector' => '{{WRAPPER}} .eel-post-content h5',
354 ]
355 );
356
357 $this->add_responsive_control(
358 'h5_margin',
359 [
360 'label' => __( 'Margin', 'easy-elements' ),
361 'type' => \Elementor\Controls_Manager::DIMENSIONS,
362 'size_units' => [ 'px', 'em', '%' ],
363 'selectors' => [
364 '{{WRAPPER}} .eel-post-content h5' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
365 ],
366 ]
367 );
368
369 $this->add_control(
370 'h6_heading',
371 [
372 'label' => esc_html__( 'H6 Heading', 'easy-elements' ),
373 'type' => \Elementor\Controls_Manager::HEADING,
374 'separator' => 'after',
375 ]
376 );
377
378 $this->add_control(
379 'h6_color',
380 [
381 'label' => esc_html__('Color', 'easy-elements'),
382 'type' => Controls_Manager::COLOR,
383 'selectors' => [
384 '{{WRAPPER}} .eel-post-content h6' => 'color: {{VALUE}};',
385 ],
386 ]
387 );
388
389 $this->add_group_control(
390 \Elementor\Group_Control_Typography::get_type(),
391 [
392 'name' => 'h6_typography',
393 'selector' => '{{WRAPPER}} .eel-post-content h6',
394 ]
395 );
396
397 $this->add_responsive_control(
398 'h6_margin',
399 [
400 'label' => __( 'Margin', 'easy-elements' ),
401 'type' => \Elementor\Controls_Manager::DIMENSIONS,
402 'size_units' => [ 'px', 'em', '%' ],
403 'selectors' => [
404 '{{WRAPPER}} .eel-post-content h6' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
405 ],
406 ]
407 );
408
409 $this->end_controls_section();
410
411 $this->start_controls_section(
412 'ul_content_section',
413 [
414 'label' => esc_html__('Others Style', 'easy-elements'),
415 'tab' => Controls_Manager::TAB_CONTENT,
416 ]
417 );
418
419 $this->add_control(
420 'ul_heading',
421 [
422 'label' => esc_html__( 'UL Style', 'easy-elements' ),
423 'type' => \Elementor\Controls_Manager::HEADING,
424 'separator' => 'after',
425 ]
426 );
427 $this->add_control(
428 'ul_color',
429 [
430 'label' => esc_html__('Color', 'easy-elements'),
431 'type' => Controls_Manager::COLOR,
432 'selectors' => [
433 '{{WRAPPER}} .eel-post-content ul' => 'color: {{VALUE}};',
434 ],
435 ]
436 );
437
438 $this->add_group_control(
439 \Elementor\Group_Control_Typography::get_type(),
440 [
441 'name' => 'ul_typography',
442 'selector' => '{{WRAPPER}} .eel-post-content ul',
443 ]
444 );
445
446 $this->add_responsive_control(
447 'ul_margin',
448 [
449 'label' => __( 'Margin', 'easy-elements' ),
450 'type' => \Elementor\Controls_Manager::DIMENSIONS,
451 'size_units' => [ 'px', 'em', '%' ],
452 'selectors' => [
453 '{{WRAPPER}} .eel-post-content ul' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
454 ],
455 ]
456 );
457
458 $this->add_responsive_control(
459 'ul_padding',
460 [
461 'label' => __( 'Padding', 'easy-elements' ),
462 'type' => \Elementor\Controls_Manager::DIMENSIONS,
463 'size_units' => [ 'px', 'em', '%' ],
464 'selectors' => [
465 '{{WRAPPER}} .eel-post-content ul' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
466 ],
467 ]
468 );
469
470 $this->add_control(
471 'li_heading',
472 [
473 'label' => esc_html__( 'LI Style', 'easy-elements' ),
474 'type' => \Elementor\Controls_Manager::HEADING,
475 'separator' => 'after',
476 ]
477 );
478
479 $this->add_responsive_control(
480 'li_margin',
481 [
482 'label' => __( 'Margin', 'easy-elements' ),
483 'type' => \Elementor\Controls_Manager::DIMENSIONS,
484 'size_units' => [ 'px', 'em', '%' ],
485 'selectors' => [
486 '{{WRAPPER}} .eel-post-content ul > li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
487 ],
488 ]
489 );
490
491 $this->add_responsive_control(
492 'li_padding',
493 [
494 'label' => __( 'Padding', 'easy-elements' ),
495 'type' => \Elementor\Controls_Manager::DIMENSIONS,
496 'size_units' => [ 'px', 'em', '%' ],
497 'selectors' => [
498 '{{WRAPPER}} .eel-post-content ul > li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
499 ],
500 ]
501 );
502
503 $this->add_control(
504 'p_heading',
505 [
506 'label' => esc_html__( 'Paragraph Style', 'easy-elements' ),
507 'type' => \Elementor\Controls_Manager::HEADING,
508 'separator' => 'after',
509 ]
510 );
511
512 $this->add_responsive_control(
513 'p__margin',
514 [
515 'label' => __( 'Margin', 'easy-elements' ),
516 'type' => \Elementor\Controls_Manager::DIMENSIONS,
517 'size_units' => [ 'px', 'em', '%' ],
518 'selectors' => [
519 '{{WRAPPER}} .eel-post-content p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
520 ],
521 ]
522 );
523
524 $this->add_control(
525 'p_img_heading',
526 [
527 'label' => esc_html__( 'Paragraph Image Style', 'easy-elements' ),
528 'type' => \Elementor\Controls_Manager::HEADING,
529 'separator' => 'after',
530 ]
531 );
532
533 $this->add_responsive_control(
534 'p_image_margin',
535 [
536 'label' => __( 'Margin', 'easy-elements' ),
537 'type' => \Elementor\Controls_Manager::DIMENSIONS,
538 'size_units' => [ 'px', 'em', '%' ],
539 'selectors' => [
540 '{{WRAPPER}} .eel-post-content img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
541 ],
542 ]
543 );
544
545 $this->end_controls_section();
546
547 }
548
549 protected function render() {
550 global $post;
551
552 $is_editor = defined('ELEMENTOR_VERSION') && \Elementor\Plugin::$instance->editor->is_edit_mode();
553
554 $post_id = function_exists('easyel_get_prepared_post_id') ? easyel_get_prepared_post_id() : get_the_ID();
555
556 $post_obj = get_post($post_id);
557 if ( ! $post_obj instanceof \WP_Post ) {
558 echo $is_editor
559 ? '<p>' . esc_html__('Post content will appear here on the frontend.', 'easy-elements') . '</p>'
560 : '';
561 return;
562 }
563
564 $original_post = $post;
565 $post = $post_obj;
566 setup_postdata($post);
567
568 echo '<div class="eel-post-content">';
569 if ($is_editor) {
570 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
571 echo apply_filters('the_content', $post->post_content);
572 } else {
573 $content = \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($post_id);
574 if (empty($content)) {
575
576 $content = apply_filters('the_content', $post->post_content);
577 }
578 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
579 echo $content;
580 }
581 echo '</div>';
582
583 // Restore original $post
584 wp_reset_postdata();
585 $post = $original_post;
586 }
587 }
588