PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.5.0
Easy Elements for Elementor – Addons & Website Templates v1.5.0
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 / countdown / countdown.php

countdown.php in Easy Elements for Elementor – Addons & Website Templates 1.5.0, at widgets/countdown/countdown.php

513 lines 14.5 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\Group_Control_Typography;
5
6 defined( 'ABSPATH' ) || die();
7
8 class Easyel_Count_Down_Widget extends \Elementor\Widget_Base {
9
10 public function get_name() {
11 return 'eel-countdown';
12 }
13
14 public function get_title() {
15 return __( 'Countdown', 'easy-elements' );
16 }
17
18 public function get_icon() {
19 return 'easyicon easyelIcon-countdown';
20 }
21
22 public function get_categories() {
23 return [ 'easyelements_category' ];
24 }
25
26 public function get_keywords() {
27 return [ 'Countdown', 'timer', 'schedule', 'time', 'day', 'hour', 'minute', 'second' ];
28 }
29
30 public function get_style_depends() {
31 return [
32 'eel-countdown',
33 ];
34 }
35
36 public function get_script_depends() {
37 return [
38 'eel-countdown',
39 ];
40 }
41
42 protected function register_controls() {
43
44 $this->start_controls_section(
45 'countdown_settings',
46 [
47 'label' => esc_html__('Countdown', 'easy-elements'),
48 ]
49 );
50
51 $this->add_control(
52 'day_label',
53 [
54 'label' => esc_html__( 'Days', 'easy-elements' ),
55 'type' => \Elementor\Controls_Manager::TEXT,
56 'default' => esc_html__( 'Days', 'easy-elements' ),
57 'placeholder' => esc_html__( 'Type your days here', 'easy-elements' ),
58 ]
59 );
60
61 $this->add_control(
62 'hours_label',
63 [
64 'label' => esc_html__( 'Hours', 'easy-elements' ),
65 'type' => \Elementor\Controls_Manager::TEXT,
66 'default' => esc_html__( 'Hours', 'easy-elements' ),
67 'placeholder' => esc_html__( 'Type your hours here', 'easy-elements' ),
68 ]
69 );
70
71 $this->add_control(
72 'minute_label',
73 [
74 'label' => esc_html__( 'Minute', 'easy-elements' ),
75 'type' => \Elementor\Controls_Manager::TEXT,
76 'default' => esc_html__( 'Minutes', 'easy-elements' ),
77 'placeholder' => esc_html__( 'Type your minute here', 'easy-elements' ),
78 ]
79 );
80
81 $this->add_control(
82 'seconds_label',
83 [
84 'label' => esc_html__( 'Seconds', 'easy-elements' ),
85 'type' => \Elementor\Controls_Manager::TEXT,
86 'default' => esc_html__( 'Seconds', 'easy-elements' ),
87 'placeholder' => esc_html__( 'Type your seconds here', 'easy-elements' ),
88 ]
89 );
90
91 $this->add_control(
92 'target_date',
93 [
94 'label' => esc_html__('Target Date', 'easy-elements'),
95 'type' => \Elementor\Controls_Manager::DATE_TIME,
96 'picker_options' => [
97 'enableTime' => true,
98 'time_24hr' => true,
99 ],
100 'default' => gmdate( 'Y-m-d H:i:s', strtotime( '+1 day', current_time( 'timestamp', 1 ) ) ),
101 ]
102 );
103
104 $this->add_control(
105 'cntdwn_separator',
106 [
107 'label' => esc_html__( 'Separator', 'easy-elements' ),
108 'type' => \Elementor\Controls_Manager::SELECT,
109 'default' => 'eel-cntdwn-space',
110 'options' => [
111 'eel-cntdwn-space' => esc_html__( 'Space', 'easy-elements' ),
112 'eel-cntdwn-bullets' => esc_html__( 'bullets', 'easy-elements' ),
113 'eel-cntdwn-dash' => esc_html__( 'Dash', 'easy-elements' ),
114 ],
115 ]
116 );
117
118 $this->add_control(
119 'label_down_shown',
120 [
121 'label' => esc_html__( 'Display Label Under Number', 'easy-elements' ),
122 'type' => \Elementor\Controls_Manager::SWITCHER,
123 'label_on' => esc_html__( 'Yes', 'easy-elements' ),
124 'label_off' => esc_html__( 'No', 'easy-elements' ),
125 'return_value' => 'yes',
126 'default' => 'no',
127 'selectors_dictionary' => [
128 'yes' => 'block',
129 'no' => 'inline-block',
130 ],
131 'selectors' => [
132 '{{WRAPPER}} .eel-cntdwn-item span' => 'display: {{VALUE}};',
133 ],
134 ]
135 );
136
137 $this->add_responsive_control(
138 'content_align',
139 [
140 'label' => esc_html__( 'Content Alignment', 'easy-elements' ),
141 'type' => \Elementor\Controls_Manager::CHOOSE,
142 'options' => [
143 'left' => [
144 'title' => esc_html__( 'Left', 'easy-elements' ),
145 'icon' => 'eicon-text-align-left',
146 ],
147 'center' => [
148 'title' => esc_html__( 'Center', 'easy-elements' ),
149 'icon' => 'eicon-text-align-center',
150 ],
151 'right' => [
152 'title' => esc_html__( 'Right', 'easy-elements' ),
153 'icon' => 'eicon-text-align-right',
154 ],
155 ],
156 'toggle' => true,
157 'selectors' => [
158 '{{WRAPPER}} .eel-cntdwn-item span' => 'text-align: {{VALUE}};',
159 ],
160 'condition' => [
161 'label_down_shown' => 'yes'
162 ]
163 ]
164 );
165
166 $this->end_controls_section();
167
168 $this->start_controls_section(
169 'countdown_style',
170 [
171 'label' => esc_html__('Countdown', 'easy-elements'),
172 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
173 ]
174 );
175
176 $this->add_responsive_control(
177 'mid_gap',
178 [
179 'label' => esc_html__( 'Mid Gap', 'easy-elements' ),
180 'type' => \Elementor\Controls_Manager::SLIDER,
181 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
182 'selectors' => [
183 '{{WRAPPER}} .eel-cntdwn' => 'gap: {{SIZE}}{{UNIT}};',
184 ],
185 ]
186 );
187
188 $this->add_responsive_control(
189 'separator_positon_x',
190 [
191 'label' => esc_html__( 'Separator Position (Horizontal)', 'easy-elements' ),
192 'type' => \Elementor\Controls_Manager::SLIDER,
193 'size_units' => ['%','px'],
194 'range' => [
195 'px' => [
196 'min' => 0,
197 'max' => 500,
198 ],
199 '%' => [
200 'min' => 0,
201 'max' => 200,
202 ],
203 ],
204 'default' => [
205 'size' => '',
206 'unit' => '%',
207 ],
208 'selectors' => [
209 '{{WRAPPER}} .eel-cntdwn-bullets::before, {{WRAPPER}} .eel-cntdwn-bullets::after' => 'left: {{SIZE}}{{UNIT}};',
210 '{{WRAPPER}} .eel-cntdwn-dash::before' => 'left: {{SIZE}}{{UNIT}};',
211 ],
212 'condition' => [
213 'cntdwn_separator' => ['eel-cntdwn-bullets','eel-cntdwn-dash']
214 ]
215 ]
216 );
217
218 $this->add_control(
219 'separator_color',
220 [
221 'label' => esc_html__('Separator Color', 'easy-elements'),
222 'type' => \Elementor\Controls_Manager::COLOR,
223 'selectors' => [
224 '{{WRAPPER}} .eel-cntdwn-bullets::before, {{WRAPPER}} .eel-cntdwn-bullets::after' => 'background: {{VALUE}};',
225 '{{WRAPPER}} .eel-cntdwn-dash::before' => 'background: {{VALUE}};',
226 ],
227 'condition' => [
228 'cntdwn_separator' => ['eel-cntdwn-bullets','eel-cntdwn-dash']
229 ]
230 ]
231 );
232
233 $this->add_control(
234 'item_bgcolor',
235 [
236 'label' => esc_html__('Background', 'easy-elements'),
237 'type' => \Elementor\Controls_Manager::COLOR,
238 'selectors' => [
239 '{{WRAPPER}} .eel-cntdwn-item' => 'background: {{VALUE}};',
240 ],
241 ]
242 );
243
244 $this->add_group_control(
245 \Elementor\Group_Control_Border::get_type(),
246 [
247 'name' => 'item_border',
248 'selector' => '{{WRAPPER}} .eel-cntdwn-item',
249 ]
250 );
251
252 $this->add_group_control(
253 \Elementor\Group_Control_Box_Shadow::get_type(),
254 [
255 'name' => 'item_box_shadow',
256 'selector' => '{{WRAPPER}} .eel-cntdwn-item',
257 ]
258 );
259
260 $this->add_responsive_control(
261 'item_border_radius',
262 [
263 'label' => esc_html__( 'Border Radius', 'easy-elements' ),
264 'type' => \Elementor\Controls_Manager::DIMENSIONS,
265 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
266 'selectors' => [
267 '{{WRAPPER}} .eel-cntdwn-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
268 ],
269 ]
270 );
271
272 $this->add_responsive_control(
273 'item_padding',
274 [
275 'label' => esc_html__( 'Padding', 'easy-elements' ),
276 'type' => \Elementor\Controls_Manager::DIMENSIONS,
277 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
278 'selectors' => [
279 '{{WRAPPER}} .eel-cntdwn-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
280 ],
281 ]
282 );
283
284 $this->end_controls_section();
285
286 // Days Style
287 $this->start_controls_section(
288 'days_style',
289 [
290 'label' => esc_html__('Days', 'easy-elements'),
291 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
292 ]
293 );
294
295 $this->add_group_control(
296 \Elementor\Group_Control_Typography::get_type(),
297 [
298 'name' => 'days_typography',
299 'label' => esc_html__('Typography', 'easy-elements'),
300 'selector' => '{{WRAPPER}} .eel-cntdwn-days',
301 ]
302 );
303
304 $this->add_control(
305 'days_color',
306 [
307 'label' => esc_html__('Color', 'easy-elements'),
308 'type' => \Elementor\Controls_Manager::COLOR,
309 'selectors' => [
310 '{{WRAPPER}} .eel-cntdwn-days' => 'color: {{VALUE}};',
311 ],
312 ]
313 );
314
315 $this->add_control(
316 'days_label_color',
317 [
318 'label' => esc_html__('Label Color', 'easy-elements'),
319 'type' => \Elementor\Controls_Manager::COLOR,
320 'selectors' => [
321 '{{WRAPPER}} .eel-cntdwn-days-label' => 'color: {{VALUE}};',
322 ],
323 ]
324 );
325
326 $this->add_group_control(
327 \Elementor\Group_Control_Typography::get_type(),
328 [
329 'name' => 'days_label_typography',
330 'label' => esc_html__('Typography', 'easy-elements'),
331 'selector' => '{{WRAPPER}} .eel-cntdwn-days-label',
332 ]
333 );
334 $this->end_controls_section();
335
336 // Hours Style
337 $this->start_controls_section(
338 'hours_style',
339 [
340 'label' => esc_html__('Hours', 'easy-elements'),
341 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
342 ]
343 );
344
345 $this->add_group_control(
346 \Elementor\Group_Control_Typography::get_type(),
347 [
348 'name' => 'hours_typography',
349 'label' => esc_html__('Typography', 'easy-elements'),
350 'selector' => '{{WRAPPER}} .eel-cntdwn-hours',
351 ]
352 );
353
354 $this->add_control(
355 'hours_color',
356 [
357 'label' => esc_html__('Color', 'easy-elements'),
358 'type' => \Elementor\Controls_Manager::COLOR,
359 'selectors' => [
360 '{{WRAPPER}} .eel-cntdwn-hours' => 'color: {{VALUE}} !important;',
361 ],
362 ]
363 );
364
365 $this->add_control(
366 'hours_label_color',
367 [
368 'label' => esc_html__('Label Color', 'easy-elements'),
369 'type' => \Elementor\Controls_Manager::COLOR,
370 'selectors' => [
371 '{{WRAPPER}} .eel-cntdwn-hours-label' => 'color: {{VALUE}};',
372 ],
373 ]
374 );
375
376 $this->add_group_control(
377 \Elementor\Group_Control_Typography::get_type(),
378 [
379 'name' => 'hours_label_typography',
380 'label' => esc_html__('Typography', 'easy-elements'),
381 'selector' => '{{WRAPPER}} .eel-cntdwn-hours-label',
382 ]
383 );
384 $this->end_controls_section();
385
386 // Minutes Style
387 $this->start_controls_section(
388 'minutes_style',
389 [
390 'label' => esc_html__('Minute', 'easy-elements'),
391 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
392 ]
393 );
394
395 $this->add_group_control(
396 \Elementor\Group_Control_Typography::get_type(),
397 [
398 'name' => 'minutes_typography',
399 'label' => esc_html__('Typography', 'easy-elements'),
400 'selector' => '{{WRAPPER}} .eel-cntdwn-minutes',
401 ]
402 );
403
404 $this->add_control(
405 'minutes_color',
406 [
407 'label' => esc_html__('Color', 'easy-elements'),
408 'type' => \Elementor\Controls_Manager::COLOR,
409 'selectors' => [
410 '{{WRAPPER}} .eel-cntdwn-minutes' => 'color: {{VALUE}};',
411 ],
412 ]
413 );
414
415 $this->add_control(
416 'minutes_label_color',
417 [
418 'label' => esc_html__('Label Color', 'easy-elements'),
419 'type' => \Elementor\Controls_Manager::COLOR,
420 'selectors' => [
421 '{{WRAPPER}} .eel-cntdwn-minutes-label' => 'color: {{VALUE}};',
422 ],
423 ]
424 );
425
426 $this->add_group_control(
427 \Elementor\Group_Control_Typography::get_type(),
428 [
429 'name' => 'minutes_label_typography',
430 'label' => esc_html__('Typography', 'easy-elements'),
431 'selector' => '{{WRAPPER}} .eel-cntdwn-minutes-label',
432 ]
433 );
434 $this->end_controls_section();
435
436 // Seconds Style
437 $this->start_controls_section(
438 'seconds_style',
439 [
440 'label' => esc_html__('Seconds', 'easy-elements'),
441 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
442 ]
443 );
444
445 $this->add_group_control(
446 \Elementor\Group_Control_Typography::get_type(),
447 [
448 'name' => 'seconds_typography',
449 'label' => esc_html__('Typography', 'easy-elements'),
450 'selector' => '{{WRAPPER}} .eel-cntdwn-seconds',
451 ]
452 );
453
454 $this->add_control(
455 'seconds_color',
456 [
457 'label' => esc_html__('Color', 'easy-elements'),
458 'type' => \Elementor\Controls_Manager::COLOR,
459 'selectors' => [
460 '{{WRAPPER}} .eel-cntdwn-seconds' => 'color: {{VALUE}};',
461 ],
462 ]
463 );
464
465 $this->add_control(
466 'seconds_label_color',
467 [
468 'label' => esc_html__('Label Color', 'easy-elements'),
469 'type' => \Elementor\Controls_Manager::COLOR,
470 'selectors' => [
471 '{{WRAPPER}} .eel-cntdwn-seconds-label' => 'color: {{VALUE}};',
472 ],
473 ]
474 );
475
476 $this->add_group_control(
477 \Elementor\Group_Control_Typography::get_type(),
478 [
479 'name' => 'seconds_label_typography',
480 'label' => esc_html__('Typography', 'easy-elements'),
481 'selector' => '{{WRAPPER}} .eel-cntdwn-seconds-label',
482 ]
483 );
484 $this->end_controls_section();
485 }
486
487 protected function render() {
488
489 $settings = $this->get_settings_for_display();
490
491 $target_date = !empty($settings['target_date'])
492 ? gmdate( 'Y-m-d H:i:s', strtotime( $settings['target_date'] ) )
493 : gmdate( 'Y-m-d H:i:s', strtotime( '+1 day', current_time( 'timestamp', 1 ) ) );
494
495 // labels
496 $day_label = !empty($settings['day_label']) ? $settings['day_label'] : 'Days';
497 $hours_label = !empty($settings['hours_label']) ? $settings['hours_label'] : 'Hours';
498 $minute_label = !empty($settings['minute_label']) ? $settings['minute_label'] : 'Minutes';
499 $seconds_label = !empty($settings['seconds_label']) ? $settings['seconds_label'] : 'Seconds';
500
501 $separator = !empty($settings['cntdwn_separator']) ? $settings['cntdwn_separator'] : 'default';
502 ?>
503 <div id="eel-countdowns" data-target="<?php echo esc_attr($target_date); ?>">
504 <div class="eel-cntdwn">
505 <div class="eel-cntdwn-item <?php echo esc_attr($separator); ?>"><span class="eel-cntdwn-days"></span> <span class="eel-cntdwn-days-label"><?php echo wp_kses_post($day_label); ?></span></div>
506 <div class="eel-cntdwn-item <?php echo esc_attr($separator); ?>"><span class="eel-cntdwn-hours"></span> <span class="eel-cntdwn-hours-label"><?php echo wp_kses_post($hours_label); ?></span></div>
507 <div class="eel-cntdwn-item <?php echo esc_attr($separator); ?>"><span class="eel-cntdwn-minutes"></span> <span class="eel-cntdwn-minutes-label"><?php echo wp_kses_post($minute_label); ?></span></div>
508 <div class="eel-cntdwn-item <?php echo esc_attr($separator); ?>"><span class="eel-cntdwn-seconds"></span> <span class="eel-cntdwn-seconds-label"><?php echo wp_kses_post($seconds_label); ?></span></div>
509 </div>
510 </div>
511 <?php
512 }
513 }