Plugin Directory

source: ht-mega-for-elementor/trunk/includes/widgets/htmega_countdown.php

Last change on this file was 3234495, checked in by devitemsllc, 3 months ago

Update to version 2.8.2 from GitHub

File size: 51.2 KB
Line 
1<?php
2namespace Elementor;
3
4if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
6class HTMega_Elementor_Widget_Countdown extends Widget_Base {
7
8    public function get_name() {
9        return 'htmega-countdown-addons';
10    }
11   
12    public function get_title() {
13        return __( 'Countdown', 'htmega-addons' );
14    }
15
16    public function get_icon() {
17        return 'htmega-icon eicon-countdown';
18    }
19
20    public function get_categories() {
21        return [ 'htmega-addons' ];
22    }
23
24    public function get_script_depends() {
25        return [
26            'htmega-countdown',
27        ];
28    }
29
30    public function get_event_list() {
31
32        if( is_plugin_active('the-events-calendar/the-events-calendar.php') ) {
33            $event_item = get_posts(array(
34                'fields'         => 'ids',
35                'posts_per_page' => -1,
36                'post_type'      => \Tribe__Events__Main::POSTTYPE,
37            ));
38
39            $event_items = ['0' => __( 'Select Event', 'htmega-addons' ) ];
40
41            foreach ($event_item as $key => $value) {
42                $event_items[$value] = get_the_title($value);
43            }
44
45            wp_reset_postdata();
46        } else {
47            $event_items = ['0' => __( 'Event Calendar Not Installed', 'htmega-addons' ) ];
48        }
49        return $event_items;
50    }
51    public function get_keywords() {
52        return ['countndown', 'counter', 'event countdown', 'upcomming', 'htmega', 'ht mega', 'addons'];
53    }
54
55    public function get_help_url() {
56        return 'https://wphtmega.com/docs/general-widgets/countdown-widget/';
57    }
58    protected function register_controls() {
59
60        // Start Date option tab
61        $this->start_controls_section(
62            'countdown_content',
63            [
64                'label' => __( 'Countdown', 'htmega-addons' ),
65            ]
66        );
67       
68            $this->add_control(
69                'show_event_list',
70                [
71                    'label'   => __( 'Event Countdown', 'htmega-addons' ),
72                    'type'    => Controls_Manager::SWITCHER,
73                    'default' => 'no',
74                ]
75            );
76
77            $this->add_control(
78                'event_id',
79                [
80                    'label'       => __( 'Event List', 'htmega-addons' ),
81                    'type'        => Controls_Manager::SELECT,
82                    'options'     => $this->get_event_list(),
83                    'default'     => '0',
84                    'condition'=>[
85                        'show_event_list'=>'yes',
86                    ]
87                ]
88            );
89
90            $this->add_control(
91                'htmega_count_style',
92                [
93                    'label'          => __( 'Style', 'htmega-addons' ),
94                    'type'           => 'htmega-preset-select',
95                    'default'        => '1',
96                    'options'        => [
97                        '1' => __( 'Style one', 'htmega-addons' ),
98                        '2' => __( 'Style Two', 'htmega-addons' ),
99                        '3' => __( 'Style Three', 'htmega-addons' ),
100                        'flip' => __( 'Style Four (Flip)', 'htmega-addons' ),
101                    ],
102                ]
103            );
104
105            $this->add_control(
106                'target_date',
107                [
108                    'label'       => __( 'Due Date', 'htmega-addons' ),
109                    'type'        => Controls_Manager::DATE_TIME,
110                    'picker_options'=>array(
111                        'dateFormat' =>"Y/m/d",
112                    ),
113                    'default'     => gmdate( 'Y/m/d', strtotime( '+1 month' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ),
114                    'condition'=>[
115                        'show_event_list!'=>'yes',
116                    ]
117                ]
118            );
119
120            $this->add_control(
121                'counter_timing_heading',
122                [
123                    'label' => __( 'Time Setting', 'htmega-addons' ),
124                    'type' => Controls_Manager::HEADING,
125                ]
126            );
127
128            $this->add_control(
129                'count_down_days',
130                [
131                    'label'        => __( 'Day', 'htmega-addons' ),
132                    'type'         => Controls_Manager::SWITCHER,
133                    'return_value' => 'yes',
134                    'default' =>'yes',
135                ]
136            );
137
138            $this->add_control(
139                'count_down_hours',
140                [
141                    'label'        => __( 'Hours', 'htmega-addons' ),
142                    'type'         => Controls_Manager::SWITCHER,
143                    'return_value' => 'yes',
144                    'default' =>'yes',
145                ]
146            );
147
148            $this->add_control(
149                'count_down_miniute',
150                [
151                    'label'        => __( 'Minutes', 'htmega-addons' ),
152                    'type'         => Controls_Manager::SWITCHER,
153                    'return_value' => 'yes',
154                    'default' =>'yes',
155                ]
156            );
157
158            $this->add_control(
159                'count_down_second',
160                [
161                    'label'        => __( 'Seconds', 'htmega-addons' ),
162                    'type'         => Controls_Manager::SWITCHER,
163                    'return_value' => 'yes',
164                    'default' =>'yes',
165                ]
166            );
167
168            $this->add_control(
169                'counter_lavel_heading',
170                [
171                    'label' => __( 'Label Setting', 'htmega-addons' ),
172                    'type' => Controls_Manager::HEADING,
173                ]
174            );
175
176            $this->add_control(
177                'count_down_labels',
178                [
179                    'label'        => __( 'Hide Label', 'htmega-addons' ),
180                    'type'         => Controls_Manager::SWITCHER,
181                    'return_value' => 'yes',
182                    'default' =>'no',
183                ]
184            );
185
186            $this->add_control(
187                'custom_labels',
188                [
189                    'label'        => __( 'Custom Label', 'htmega-addons' ),
190                    'type'         => Controls_Manager::SWITCHER,
191                    'return_value' => 'yes',
192                    'condition'   => [
193                        'count_down_labels!' => 'yes',
194                    ],
195                ]
196            );
197
198            $this->add_control(
199                'customlabel_days',
200                [
201                    'label'       => __( 'Days', 'htmega-addons' ),
202                    'type'        => Controls_Manager::TEXT,
203                    'placeholder' => __( 'Days', 'htmega-addons' ),
204                    'condition'   => [
205                        'custom_labels!'     => '',
206                        'count_down_labels!' => 'yes',
207                        'count_down_days'    => 'yes',
208                    ],
209                ]
210            );
211
212            $this->add_control(
213                'customlabel_hours',
214                [
215                    'label'       => __( 'Hours', 'htmega-addons' ),
216                    'type'        => Controls_Manager::TEXT,
217                    'placeholder' => __( 'Hours', 'htmega-addons' ),
218                    'condition'   => [
219                        'custom_labels!'     => '',
220                        'count_down_labels!' => 'yes',
221                        'count_down_hours'   => 'yes',
222                    ],
223                ]
224            );
225
226            $this->add_control(
227                'customlabel_minutes',
228                [
229                    'label'       => __( 'Minutes', 'htmega-addons' ),
230                    'type'        => Controls_Manager::TEXT,
231                    'placeholder' => __( 'Minutes', 'htmega-addons' ),
232                    'condition'   => [
233                        'custom_labels!'     => '',
234                        'count_down_labels!' => 'yes',
235                        'count_down_miniute' => 'yes',
236                    ],
237                ]
238            );
239
240            $this->add_control(
241                'customlabel_seconds',
242                [
243                    'label'       => __( 'Seconds', 'htmega-addons' ),
244                    'type'        => Controls_Manager::TEXT,
245                    'placeholder' => __( 'Seconds', 'htmega-addons' ),
246                    'condition'   => [
247                        'custom_labels!'     => '',
248                        'count_down_labels!' => 'yes',
249                        'count_down_second'  => 'yes',
250                    ],
251                ]
252            );
253
254        $this->end_controls_section(); // Date Optiin end
255
256        // Event Button
257        $this->start_controls_section(
258            'countdown_event_button',
259            [
260                'label' => __( 'Event Button', 'htmega-addons' ),
261                'condition'=>[
262                    'show_event_list'=>'yes',
263                ]
264            ]
265        );
266           
267            $this->add_control(
268                'button_text',
269                [
270                    'label' => __( 'Text', 'htmega-addons' ),
271                    'type' => Controls_Manager::TEXT,
272                    'default'=>__('Details','htmega-addons'),
273                ]
274            );
275
276            $this->add_control(
277                'button_icon',
278                [
279                    'label' => __( 'Icon', 'htmega-addons' ),
280                    'type' => Controls_Manager::ICONS,
281                ]
282            );
283
284        $this->end_controls_section(); // Date Optiin end
285
286        // Content Layout
287        $this->start_controls_section(
288            'countdown_layout',
289            [
290                'label' => __( 'Count Layout', 'htmega-addons' ),
291                'tab' => Controls_Manager::TAB_STYLE,
292            ]
293        );
294           
295           
296            $this->add_responsive_control(
297                'column_width',
298                [
299                    'label'   => __( 'Column Width', 'htmega-addons' ),
300                    'type'    => Controls_Manager::SLIDER,
301                    'default' => [
302                        'unit' => 'px',
303                        'size' => 139,
304                    ],
305                    'tablet_default' => [
306                        'unit' => '%',
307                    ],
308                    'mobile_default' => [
309                        'unit' => '%',
310                    ],
311                    'range' => [
312                        'px' => [
313                            'min' => 0,
314                            'max' => 2000,
315                        ],
316                        '%' => [
317                            'min' => 0,
318                            'max' => 100,
319                        ],
320                    ],
321                    'size_units' => [ '%', 'px' ],
322                    'selectors'  => [
323                        '{{WRAPPER}} span.ht-count' => 'width: {{SIZE}}{{UNIT}};',
324                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner' => 'width: {{SIZE}}{{UNIT}};',
325                    ],
326                    'condition'   => [
327                        'htmega_count_style' => ['1', 'flip'],
328                    ],
329                ]
330            );
331
332            $this->add_responsive_control(
333                'column_height',
334                [
335                    'label'   => __( 'Column Height', 'htmega-addons' ),
336                    'type'    => Controls_Manager::SLIDER,
337                    'default' => [
338                        'unit' => 'px',
339                        'size' => 185,
340                    ],
341                    'tablet_default' => [
342                        'unit' => '%',
343                    ],
344                    'mobile_default' => [
345                        'unit' => '%',
346                    ],
347                    'range' => [
348                        'px' => [
349                            'min' => 0,
350                            'max' => 2000,
351                        ],
352                        '%' => [
353                            'min' => 0,
354                            'max' => 100,
355                        ],
356                    ],
357                    'size_units' => [ '%', 'px' ],
358                    'selectors'  => [
359                        '{{WRAPPER}} span.ht-count' => 'height: {{SIZE}}{{UNIT}};',
360                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner' => 'height: {{SIZE}}{{UNIT}};',
361                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner .htmega-top' => 'line-height: {{SIZE}}{{UNIT}};',
362                    ],
363                    'condition'   => [
364                        'htmega_count_style' => ['1', 'flip'],
365                    ],
366                ]
367            );
368
369            $this->add_responsive_control(
370                'count_down_specing',
371                [
372                    'label' => __( 'Column Spacing', 'htmega-addons' ),
373                    'type' => Controls_Manager::SLIDER,
374                    'size_units' => [ 'px', '%' ],
375                    'range' => [
376                        'px' => [
377                            'min' => 0,
378                            'max' => 200,
379                            'step' => 1,
380                        ],
381                        '%' => [
382                            'min' => 0,
383                            'max' => 100,
384                        ],
385                    ],
386                    'default' => [
387                        'unit' => 'px',
388                        'size' => 22,
389                    ],
390                    'selectors' => [
391                        '{{WRAPPER}} .htmega-countbox .ht-count' => 'margin-right: {{SIZE}}{{UNIT}};',
392                        '{{WRAPPER}} .htmega-flash-flip-countdown-timer .ht-countdown-flip .htmega-time' => 'margin-right: {{SIZE}}{{UNIT}};',
393                    ],
394                ]
395            );
396
397        $this->end_controls_section();
398
399        // Style tab section
400        $this->start_controls_section(
401            'htmega_countdown_style',
402            [
403                'label' => __( 'Count Area', 'htmega-addons' ),
404                'tab' => Controls_Manager::TAB_STYLE,
405            ]
406        );
407
408            $this->add_group_control(
409                Group_Control_Background::get_type(),
410                [
411                    'name' => 'counter_background',
412                    'label' => __( 'Background', 'htmega-addons' ),
413                    'types' => [ 'classic', 'gradient' ],
414                    'selector' => '{{WRAPPER}} span.ht-count',
415                    'condition'=>[
416                        'htmega_count_style'=> ['1', '2', '3'],
417                    ]
418                ]
419            );
420
421            $this->add_control(
422                'counter_background_daly_heading',
423                [
424                    'label' => esc_html__( '1. Background Days', 'htmega-addons' ),
425                    'type' => Controls_Manager::HEADING,
426                    'condition'=>[
427                        'htmega_count_style'=> 'flip',
428                    ],
429                    'separator' => 'after',
430                ]
431            );
432
433            $this->add_group_control(
434                Group_Control_Background::get_type(),
435                [
436                    'name' => 'counter_background_daly_flip',
437                    'label' => __( 'Background', 'htmega-addons' ),
438                    'types' => [ 'classic', 'gradient' ],
439                    'selector' => '{{WRAPPER}} .htmega-flash-flip-countdown-timer .ht-countdown .htmega-days .ht-count',
440                    'condition'=>[
441                        'htmega_count_style'=> 'flip',
442                    ],
443                ]
444            );
445
446            $this->add_control(
447                'counter_background_hours_heading',
448                [
449                    'label' => esc_html__( '2. Background Hours', 'htmega-addons' ),
450                    'type' => Controls_Manager::HEADING,
451                    'separator' => 'after',
452                    'condition'=>[
453                        'htmega_count_style'=> 'flip',
454                    ]
455                ]
456            );
457
458            $this->add_group_control(
459                Group_Control_Background::get_type(),
460                [
461                    'name' => 'counter_background_hours_flip',
462                    'label' => __( 'Background', 'htmega-addons' ),
463                    'types' => [ 'classic', 'gradient' ],
464                    'selector' => '{{WRAPPER}} .htmega-flash-flip-countdown-timer .ht-countdown .htmega-hours .ht-count',
465                    'condition'=>[
466                        'htmega_count_style'=> 'flip',
467                    ],
468                ]
469            );
470
471            $this->add_control(
472                'counter_background_minutes_heading',
473                [
474                    'label' => esc_html__( '3. Background Minutes', 'htmega-addons' ),
475                    'type' => Controls_Manager::HEADING,
476                    'separator' => 'after',
477                    'condition'=>[
478                        'htmega_count_style'=> 'flip',
479                    ]
480                ]
481            );
482
483            $this->add_group_control(
484                Group_Control_Background::get_type(),
485                [
486                    'name' => 'counter_background_minutes_flip',
487                    'label' => __( 'Background', 'htmega-addons' ),
488                    'types' => [ 'classic', 'gradient' ],
489                    'selector' => '{{WRAPPER}} .htmega-flash-flip-countdown-timer .ht-countdown .htmega-mins .ht-count',
490                    'condition'=>[
491                        'htmega_count_style'=> 'flip',
492                    ],
493                ]
494            );
495
496            $this->add_control(
497                'counter_background_seconds_heading',
498                [
499                    'label' => esc_html__( '4. Background Seconds', 'htmega-addons' ),
500                    'type' => Controls_Manager::HEADING,
501                    'separator' => 'after',
502                    'condition'=>[
503                        'htmega_count_style'=> 'flip',
504                    ]
505                ]
506            );
507
508            $this->add_group_control(
509                Group_Control_Background::get_type(),
510                [
511                    'name' => 'counter_background_seconds_flip',
512                    'label' => __( 'Background', 'htmega-addons' ),
513                    'types' => [ 'classic', 'gradient' ],
514                    'selector' => '{{WRAPPER}} .htmega-flash-flip-countdown-timer .ht-countdown .htmega-secs .ht-count',
515                    'condition'=>[
516                        'htmega_count_style'=> 'flip',
517                    ],
518                ]
519            );
520
521            $this->add_group_control(
522                Group_Control_Box_Shadow::get_type(),
523                [
524                    'name' => 'counter_box_shadow',
525                    'label' => __( 'Box Shadow', 'htmega-addons' ),
526                    'selector' => '{{WRAPPER}} span.ht-count, {{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner',
527                ]
528            );
529
530            $this->add_group_control(
531                Group_Control_Border::get_type(),
532                [
533                    'name' => 'countborder',
534                    'label' => __( 'Border', 'htmega-addons' ),
535                    'selector' => '{{WRAPPER}} span.ht-count',
536                    'condition'=>[
537                        'htmega_count_style'=> ['1', '2', '3'],
538                    ]
539                ]
540            );
541
542            $this->add_group_control(
543                Group_Control_Border::get_type(),
544                [
545                    'name' => 'countborder_flip',
546                    'label' => __( 'Border', 'htmega-addons' ),
547                    'selector' => '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner',
548                    'condition'=>[
549                        'htmega_count_style'=> 'flip',
550                    ]
551                ]
552            );
553           
554
555            $this->add_responsive_control(
556                'count_border_radius',
557                [
558                    'label' => __( 'Border Radius', 'htmega-addons' ),
559                    'type' => Controls_Manager::DIMENSIONS,
560                    'selectors' => [
561                        '{{WRAPPER}} span.ht-count' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
562                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
563                    ],
564                    'separator' =>'before',
565                    'condition'=>[
566                        'htmega_count_style'=> ['1', '2', '3'],
567                    ]
568                ]
569            );
570
571            $this->add_responsive_control(
572                'countpadding',
573                [
574                    'label' => __( 'Padding', 'htmega-addons' ),
575                    'type' => Controls_Manager::DIMENSIONS,
576                    'size_units' => [ 'px', '%', 'em' ],
577                    'selectors' => [
578                        '{{WRAPPER}} span.ht-count' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
579                    ],
580                    'separator' =>'before',
581                    'condition'=>[
582                        'htmega_count_style'=> ['1', '2', '3'],
583                    ]
584                ]
585            );
586
587            $this->add_responsive_control(
588                'countmargin',
589                [
590                    'label' => __( 'Margin', 'htmega-addons' ),
591                    'type' => Controls_Manager::DIMENSIONS,
592                    'size_units' => [ 'px', '%', 'em' ],
593                    'selectors' => [
594                        '{{WRAPPER}} span.ht-count' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
595                    ],
596                    'separator' =>'before',
597                    'condition'=>[
598                        'htmega_count_style'=> ['1', '2', '3'],
599                    ]
600                ]
601            );
602
603            $this->add_responsive_control(
604                'itemaligntitle',
605                [
606                    'label' => __( 'Item Alignment', 'htmega-addons' ),
607                    'type' => Controls_Manager::CHOOSE,
608                    'options' => [
609                        'left' => [
610                            'title' => __( 'Left', 'htmega-addons' ),
611                            'icon' => 'eicon-text-align-left',
612                        ],
613                        'center' => [
614                            'title' => __( 'Center', 'htmega-addons' ),
615                            'icon' => 'eicon-text-align-center',
616                        ],
617                        'right' => [
618                            'title' => __( 'Right', 'htmega-addons' ),
619                            'icon' => 'eicon-text-align-right',
620                        ],
621                        'justify' => [
622                            'title' => __( 'Justified', 'htmega-addons' ),
623                            'icon' => 'eicon-text-align-justify',
624                        ],
625                    ],
626                    'selectors' => [
627                        '{{WRAPPER}} .htmega-countbox' => 'text-align: {{VALUE}};',
628                        '{{WRAPPER}} .ht-countdown-flip' => 'justify-content: {{VALUE}};',
629                    ],
630                    'prefix_class' => 'htmega-item-align%s-',
631                    'default' => '',
632                ]
633            );
634
635            $this->add_responsive_control(
636                'aligntitle',
637                [
638                    'label' => __( 'Content Alignment', 'htmega-addons' ),
639                    'type' => Controls_Manager::CHOOSE,
640                    'options' => [
641                        'left' => [
642                            'title' => __( 'Left', 'htmega-addons' ),
643                            'icon' => 'eicon-text-align-left',
644                        ],
645                        'center' => [
646                            'title' => __( 'Center', 'htmega-addons' ),
647                            'icon' => 'eicon-text-align-center',
648                        ],
649                        'right' => [
650                            'title' => __( 'Right', 'htmega-addons' ),
651                            'icon' => 'eicon-text-align-right',
652                        ],
653                        'justify' => [
654                            'title' => __( 'Justified', 'htmega-addons' ),
655                            'icon' => 'eicon-text-align-justify',
656                        ],
657                    ],
658                    'selectors' => [
659                        '{{WRAPPER}} span.ht-count' => 'text-align: {{VALUE}};',
660                    ],
661                    'default' => 'center',
662                    'prefix_class' => 'htmega-count-align%s-',
663                    'condition'=>[
664                        'htmega_count_style'=> ['1', '2', '3'],
665                    ]
666                ]
667            );
668
669            $this->add_control(
670                'counter_separator',
671                [
672                    'label'        => __( 'Counter separator', 'htmega-addons' ),
673                    'type'         => Controls_Manager::SWITCHER,
674                    'return_value' => 'yes',
675                    'default' =>'yes',
676                    'separator' =>'before',
677                    'condition'=>[
678                        'htmega_count_style'=> ['1', '2', '3'],
679                    ]
680                ]
681            );
682
683            $this->add_control(
684                'count_seperator_color',
685                [
686                    'label' => __( 'Color', 'htmega-addons' ),
687                    'type' => Controls_Manager::COLOR,
688                    'default' => '#5e5b60',
689                    'selectors' => [
690                        '{{WRAPPER}} .htmega-countbox .ht-count::before' => 'color: {{VALUE}};',
691                    ],
692                    'condition'=>[
693                        'counter_separator'=>'yes',
694                        'htmega_count_style'=> ['1', '2', '3'],
695                    ]
696                ]
697            );
698
699            $this->add_control(
700                'count_seperator_image',
701                [
702                    'label' => esc_html__( 'Choose Area Seperator Image', 'htmega-addons' ),
703                    'type' => Controls_Manager::MEDIA,
704                    'condition'=>[
705                        'counter_separator'=>'yes',
706                        'htmega_count_style'=> ['1', '2', '3'],
707                    ]
708                ]
709            );
710
711           
712            $this->add_responsive_control(
713                'count_timer_separator_position',
714                [
715                    'label' => esc_html__( 'Separator Position', 'htmega-addons' ),
716                    'type' => Controls_Manager::SLIDER,
717                    'size_units' => [ 'px' ],
718                    'range' => [
719                        'px' => [
720                            'min' => -100,
721                            'max' => 100,
722                        ],
723                    ],
724                    'selectors' => [
725                        '{{WRAPPER}} .htmega-countbox .ht-count::before' => 'right: {{SIZE}}{{UNIT}};',
726                    ],
727                    'condition'=>[
728                        'counter_separator' => 'yes',
729                        'htmega_count_style'=> ['1', '2', '3'],
730                    ],
731                ]
732            );
733
734        $this->end_controls_section(); // Section style tab end
735
736        // Timer style tab start
737        $this->start_controls_section(
738            'htmega_countdown_time_style',
739            [
740                'label'     => __( 'Timer', 'htmega-addons' ),
741                'tab'       => Controls_Manager::TAB_STYLE,
742            ]
743        );
744           
745            $this->add_control(
746                'count_timer_color',
747                [
748                    'label' => __( 'Color', 'htmega-addons' ),
749                    'type' => Controls_Manager::COLOR,
750                    'default' => '#242424',
751                    'selectors' => [
752                        '{{WRAPPER}} .htmega-countbox span.time-count' => 'color: {{VALUE}};',
753                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner .ht-count' => 'color: {{VALUE}};',
754                    ],
755                ]
756            );
757
758            $this->add_group_control(
759                Group_Control_Typography::get_type(),
760                [
761                    'name' => 'count_timer_typography',
762                    'selector' => '{{WRAPPER}} .htmega-countbox span.time-count, {{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-time-inner .ht-count',
763                ]
764            );
765
766            $this->add_group_control(
767                Group_Control_Text_Shadow::get_type(),
768                [
769                    'name' => 'count_timer_shadow',
770                    'label' => __( 'Text Shadow', 'htmega-addons' ),
771                    'selector' => '{{WRAPPER}} .htmega-countbox span.time-count',
772                    'condition'=>[
773                        'htmega_count_style'=> ['1', '2', '3'],
774                    ]
775                ]
776            );
777
778            $this->add_group_control(
779                Group_Control_Background::get_type(),
780                [
781                    'name' => 'count_timer_background',
782                    'label' => __( 'Background', 'htmega-addons' ),
783                    'types' => [ 'classic', 'gradient' ],
784                    'selector' => '{{WRAPPER}} .htmega-countbox span.time-count',
785                    'condition'=>[
786                        'htmega_count_style'=> ['1', '2', '3'],
787                    ]
788                ]
789            );
790
791            $this->add_group_control(
792                Group_Control_Border::get_type(),
793                [
794                    'name' => 'count_timer_border',
795                    'label' => __( 'Border', 'htmega-addons' ),
796                    'selector' => '{{WRAPPER}} .htmega-countbox span.time-count',
797                    'condition'=>[
798                        'htmega_count_style'=> ['1', '2', '3'],
799                    ]
800                ]
801            );
802
803            $this->add_responsive_control(
804                'count_timer_border_radius',
805                [
806                    'label' => __( 'Border Radius', 'htmega-addons' ),
807                    'type' => Controls_Manager::DIMENSIONS,
808                    'selectors' => [
809                        '{{WRAPPER}} .htmega-countbox span.time-count' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
810                    ],
811                    'separator' =>'before',
812                    'condition'=>[
813                        'htmega_count_style'=> ['1', '2', '3'],
814                    ]
815                ]
816            );
817
818            $this->add_responsive_control(
819                'count_timer_padding',
820                [
821                    'label' => __( 'Padding', 'htmega-addons' ),
822                    'type' => Controls_Manager::DIMENSIONS,
823                    'size_units' => [ 'px', '%', 'em' ],
824                    'selectors' => [
825                        '{{WRAPPER}} .htmega-countbox span.time-count' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
826                    ],
827                    'separator' =>'before',
828                    'condition'=>[
829                        'htmega_count_style'=> ['1', '2', '3'],
830                    ]
831                ]
832            );
833
834            $this->add_responsive_control(
835                'count_timer_margin',
836                [
837                    'label' => __( 'Margin', 'htmega-addons' ),
838                    'type' => Controls_Manager::DIMENSIONS,
839                    'size_units' => [ 'px', '%', 'em' ],
840                    'selectors' => [
841                        '{{WRAPPER}} .htmega-countbox span.time-count' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
842                    ],
843                    'separator' =>'before',
844                    'condition'=>[
845                        'htmega_count_style'=> ['1', '2', '3'],
846                    ]
847                ]
848            );
849
850            $this->add_control(
851                'counter_timer_separator',
852                [
853                    'label'        => __( 'Timer separator', 'htmega-addons' ),
854                    'type'         => Controls_Manager::SWITCHER,
855                    'return_value' => 'yes',
856                    'default' =>'yes',
857                    'condition'=>[
858                        'htmega_count_style'=> ['1', '2', '3'],
859                    ]
860                ]
861               
862            );
863
864            $this->add_group_control(
865                Group_Control_Background::get_type(),
866                [
867                    'name' => 'count_timer_separator_background',
868                    'label' => __( 'Background', 'htmega-addons' ),
869                    'types' => [ 'gradient' ],
870                    'selector' => '{{WRAPPER}} .htmega-countbox span.time-count::before',
871                    'condition'=>[
872                        'counter_timer_separator' => 'yes',
873                        'htmega_count_style'=> ['1', '2', '3'],
874                    ]
875                ]
876            );
877
878            $this->add_control(
879                'count_timer_separator_background_width',
880                [
881                    'label' => esc_html__( 'Separator Width', 'htmega-addons' ),
882                    'type' => Controls_Manager::SLIDER,
883                    'size_units' => [ '%' ],
884                    'range' => [
885                        '%' => [
886                            'min' => 0,
887                            'max' => 100,
888                        ],
889                    ],
890                    'default' => [
891                        'unit' => '%',
892                        'size' => 80,
893                    ],
894                    'selectors' => [
895                        '{{WRAPPER}} .htmega-countbox span.time-count::before' => 'background-size: {{SIZE}}{{UNIT}} auto;',
896                    ],
897                    'condition'=>[
898                        'counter_timer_separator' => 'yes',
899                        'htmega_count_style'=> ['1', '2', '3'],
900                    ],
901                    'separator' =>'before',
902                ]
903            );
904
905        $this->end_controls_section(); // Timer style tab end
906
907        // Style tab section
908        $this->start_controls_section(
909            'htmega_countdown_label_style',
910            [
911                'label' => __( 'Label', 'htmega-addons' ),
912                'tab' => Controls_Manager::TAB_STYLE,
913                'condition'   => [
914                    'count_down_labels!' => 'yes',
915                ],
916            ]
917        );
918            $this->add_control(
919                'count_lavel_color',
920                [
921                    'label' => __( 'Color', 'htmega-addons' ),
922                    'type' => Controls_Manager::COLOR,
923                    'default' => '#242424',
924                    'selectors' => [
925                        '{{WRAPPER}} .htmega-countbox span span.count-inner p' => 'color: {{VALUE}};',
926                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p' => 'color: {{VALUE}};',
927                    ],
928                ]
929            );
930
931            $this->add_group_control(
932                Group_Control_Typography::get_type(),
933                [
934                    'name' => 'count_lavel_typography',
935                    'selector' => '{{WRAPPER}} .htmega-countbox span span.count-inner p, {{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p',
936                ]
937            );
938
939            $this->add_group_control(
940                Group_Control_Text_Shadow::get_type(),
941                [
942                    'name' => 'count_lavel_shadow',
943                    'label' => __( 'Text Shadow', 'htmega-addons' ),
944                    'selector' => '{{WRAPPER}} .htmega-countbox span span.count-inner p, {{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p',
945                ]
946            );
947
948            $this->add_group_control(
949                Group_Control_Background::get_type(),
950                [
951                    'name' => 'count_lavel_background',
952                    'label' => __( 'Background', 'htmega-addons' ),
953                    'types' => [ 'classic', 'gradient' ],
954                    'selector' => '{{WRAPPER}} .htmega-countbox span span.count-inner p, {{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p',
955                ]
956            );
957
958            $this->add_group_control(
959                Group_Control_Border::get_type(),
960                [
961                    'name' => 'count_lavel_border',
962                    'label' => __( 'Border', 'htmega-addons' ),
963                    'selector' => '{{WRAPPER}} .htmega-countbox span span.count-inner p, {{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p',
964                ]
965            );
966
967            $this->add_responsive_control(
968                'count_lavel_border_radius',
969                [
970                    'label' => __( 'Border Radius', 'htmega-addons' ),
971                    'type' => Controls_Manager::DIMENSIONS,
972                    'selectors' => [
973                        '{{WRAPPER}} .htmega-countbox span span.count-inner p' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
974                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
975                    ],
976                    'separator' =>'before',
977                ]
978            );
979
980            $this->add_responsive_control(
981                'count_lavel_padding',
982                [
983                    'label' => __( 'Padding', 'htmega-addons' ),
984                    'type' => Controls_Manager::DIMENSIONS,
985                    'size_units' => [ 'px', '%', 'em' ],
986                    'selectors' => [
987                        '{{WRAPPER}} .htmega-countbox span span.count-inner p' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
988                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
989                    ],
990                    'separator' =>'before',
991                ]
992            );
993
994            $this->add_responsive_control(
995                'count_lavel_margin',
996                [
997                    'label' => __( 'Margin', 'htmega-addons' ),
998                    'type' => Controls_Manager::DIMENSIONS,
999                    'size_units' => [ 'px', '%', 'em' ],
1000                    'selectors' => [
1001                        '{{WRAPPER}} .htmega-countbox span span.count-inner p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1002                        '{{WRAPPER}} .ht-countdown-flip .htmega-time .htmega-label p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1003                    ],
1004                    'separator' =>'before',
1005                ]
1006            );
1007
1008        $this->end_controls_section(); // Label style tab end
1009
1010        // Style tab section
1011        $this->start_controls_section(
1012            'button_style_section',
1013            [
1014                'label' => __( 'Button Style', 'htmega-addons' ),
1015                'tab' => Controls_Manager::TAB_STYLE,
1016                'condition'=>[
1017                    'show_event_list'=>'yes',
1018                ]
1019            ]
1020        );
1021
1022            $this->start_controls_tabs( 'button_style_tabs' );
1023           
1024                $this->start_controls_tab(
1025                    'button_style_normal_tab',
1026                    [
1027                        'label' => __( 'Normal', 'htmega-addons' ),
1028                    ]
1029                );
1030                   
1031                    $this->add_group_control(
1032                        Group_Control_Typography::get_type(),
1033                        [
1034                            'name' => 'button_typography',
1035                            'label' => __( 'Typography', 'htmega-addons' ),
1036                            'selector' => '{{WRAPPER}} .htmega_event_button a',
1037                        ]
1038                    );
1039
1040                    $this->add_control(
1041                        'button_text_color',
1042                        [
1043                            'label' => __( 'Color', 'htmega-addons' ),
1044                            'type' => Controls_Manager::COLOR,
1045                            'default' => '',
1046                            'selectors' => [
1047                                '{{WRAPPER}} .htmega_event_button a' => 'color: {{VALUE}};',
1048                            ],
1049                        ]
1050                    );
1051
1052                    $this->add_group_control(
1053                        Group_Control_Background::get_type(),
1054                        [
1055                            'name'      => 'button_background_color',
1056                            'types'     => [ 'classic', 'gradient' ],
1057                            'selector'  => '{{WRAPPER}} .htmega_event_button a',
1058                        ]
1059                    );
1060
1061                    $this->add_group_control(
1062                        Group_Control_Box_Shadow::get_type(),
1063                        [
1064                            'name' => 'button_box_shadow',
1065                            'selector' => '{{WRAPPER}} .htmega_event_button a',
1066                        ]
1067                    );
1068
1069                    $this->add_group_control(
1070                        Group_Control_Border::get_type(), [
1071                            'name' => 'button_border',
1072                            'label' => __( 'Border', 'htmega-addons' ),
1073                            'placeholder' => '1px',
1074                            'default' => '1px',
1075                            'selector' => '{{WRAPPER}} .htmega_event_button a',
1076                            'separator' => 'before',
1077                        ]
1078                    );
1079
1080                    $this->add_control(
1081                        'button_border_radius',
1082                        [
1083                            'label' => __( 'Border Radius', 'htmega-addons' ),
1084                            'type' => Controls_Manager::DIMENSIONS,
1085                            'size_units' => [ 'px', '%' ],
1086                            'selectors' => [
1087                                '{{WRAPPER}} .htmega_event_button a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1088                            ],
1089                        ]
1090                    );
1091
1092                    $this->add_control(
1093                        'button_margin',
1094                        [
1095                            'label' => __( 'Margin', 'htmega-addons' ),
1096                            'type' => Controls_Manager::DIMENSIONS,
1097                            'size_units' => [ 'px', 'em', '%' ],
1098                            'selectors' => [
1099                                '{{WRAPPER}} .htmega_event_button a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1100                            ],
1101                        ]
1102                    );
1103
1104                    $this->add_control(
1105                        'button_padding',
1106                        [
1107                            'label' => __( 'Padding', 'htmega-addons' ),
1108                            'type' => Controls_Manager::DIMENSIONS,
1109                            'size_units' => [ 'px', 'em', '%' ],
1110                            'selectors' => [
1111                                '{{WRAPPER}} .htmega_event_button a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1112                            ],
1113                        ]
1114                    );
1115
1116                $this->end_controls_tab(); // Normal Button style End
1117
1118                // Hover Button style End
1119                $this->start_controls_tab(
1120                    'button_style_hover_tab',
1121                    [
1122                        'label' => __( 'Hover', 'htmega-addons' ),
1123                    ]
1124                );
1125                    $this->add_control(
1126                        'button_hover_text_color',
1127                        [
1128                            'label' => __( 'Color', 'htmega-addons' ),
1129                            'type' => Controls_Manager::COLOR,
1130                            'default' => '',
1131                            'selectors' => [
1132                                '{{WRAPPER}} .htmega_event_button a:hover' => 'color: {{VALUE}};',
1133                            ],
1134                        ]
1135                    );
1136
1137                    $this->add_group_control(
1138                        Group_Control_Background::get_type(),
1139                        [
1140                            'name'      => 'button_hover_background_color',
1141                            'types'     => [ 'classic', 'gradient' ],
1142                            'selector'  => '{{WRAPPER}} .htmega_event_button a:hover',
1143                        ]
1144                    );
1145
1146                    $this->add_group_control(
1147                        Group_Control_Box_Shadow::get_type(),
1148                        [
1149                            'name' => 'button_hover_box_shadow',
1150                            'selector' => '{{WRAPPER}} .htmega_event_button a:hover',
1151                        ]
1152                    );
1153
1154                    $this->add_group_control(
1155                        Group_Control_Border::get_type(), [
1156                            'name' => 'button_hover_border',
1157                            'label' => __( 'Border', 'htmega-addons' ),
1158                            'placeholder' => '1px',
1159                            'default' => '1px',
1160                            'selector' => '{{WRAPPER}} .htmega_event_button a:hover',
1161                            'separator' => 'before',
1162                        ]
1163                    );
1164
1165                    $this->add_control(
1166                        'button_hover_border_radius',
1167                        [
1168                            'label' => __( 'Border Radius', 'htmega-addons' ),
1169                            'type' => Controls_Manager::DIMENSIONS,
1170                            'size_units' => [ 'px', '%' ],
1171                            'selectors' => [
1172                                '{{WRAPPER}} .htmega_event_button a:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1173                            ],
1174                        ]
1175                    );
1176
1177                $this->end_controls_tab();
1178
1179            $this->end_controls_tabs();
1180
1181        $this->end_controls_section();
1182
1183    }
1184
1185    protected function render( $instance = [] ) {
1186        $sectionid =  "htmaga-". $this-> get_id();
1187        $settings   = $this->get_settings_for_display();
1188        $data_options = [];
1189
1190        if( $settings['show_event_list'] == 'yes' && function_exists('tribe_get_start_date') ){
1191            $data_options['htmegadate']  =  tribe_get_start_date ( absint( $settings['event_id'] ), false,  'Y/m/d' );
1192        }else{ 
1193            $data_options['htmegadate'] = isset( $settings['target_date'] ) ? esc_attr( $settings['target_date'] ) : gmdate( 'Y/m/d', strtotime( '+1 month' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
1194        }
1195
1196        // Hide Countdownload item
1197        $data_options['style']      = sanitize_text_field( $settings['htmega_count_style'] );
1198        $data_options['lavelhide']      = sanitize_text_field( $settings['count_down_labels'] );
1199        $data_options['htmegaday']      = sanitize_text_field( $settings['count_down_days'] );
1200        $data_options['htmegahours']    = sanitize_text_field( $settings['count_down_hours'] );
1201        $data_options['htmegaminiute']  = sanitize_text_field( $settings['count_down_miniute'] );
1202        $data_options['htmegasecond']   = sanitize_text_field( $settings['count_down_second'] );
1203        // Custom Label
1204        $data_options['htmegadaytxt'] = ! empty( $settings['customlabel_days'] ) ? 
1205        htmlspecialchars( wp_strip_all_tags($settings['customlabel_days']) ) : 
1206        esc_html__( 'Days', 'htmega-addons' );
1207   
1208        $data_options['htmegahourtxt'] = ! empty( $settings['customlabel_hours'] ) ? 
1209            htmlspecialchars( wp_strip_all_tags($settings['customlabel_hours']) ) : 
1210            esc_html__( 'Hours', 'htmega-addons' );
1211       
1212        $data_options['htmegaminutestxt'] = ! empty( $settings['customlabel_minutes'] ) ? 
1213            htmlspecialchars( wp_strip_all_tags($settings['customlabel_minutes']) ) : 
1214            esc_html__( 'Minutes', 'htmega-addons' );
1215       
1216        $data_options['htmegasecondstxt'] = ! empty( $settings['customlabel_seconds'] ) ? 
1217            htmlspecialchars( wp_strip_all_tags($settings['customlabel_seconds']) ) : 
1218            esc_html__( 'Seconds', 'htmega-addons' );
1219
1220
1221       
1222        $this->add_render_attribute( 'countdown_wrapper_attr', 'class', 'htmega-countdown-wrapper ' . esc_attr( $sectionid ) );
1223        $this->add_render_attribute( 'countdown_wrapper_attr', 'class', 'htmega-countdown-style-'. esc_attr( $settings['htmega_count_style'] ) );
1224
1225        if( $settings['counter_timer_separator'] != 'yes' ){
1226            $this->add_render_attribute( 'countdown_wrapper_attr', 'class', 'htmega-timer-separate-no' );
1227        }
1228        if( $settings['counter_separator'] != 'yes' ){
1229            $this->add_render_attribute( 'countdown_wrapper_attr', 'class', 'htmega-separate-no' );
1230        }
1231        if( $settings['count_down_labels'] == 'yes' ){
1232            $this->add_render_attribute( 'countdown_wrapper_attr', 'class', 'htmega-hide-lavel' );
1233        }
1234
1235        if(isset($settings['count_seperator_image']['url']) &&  $settings['count_seperator_image']['url'] != ''){
1236            $count_area_seperator = "url('" . esc_url( $settings['count_seperator_image']['url'] ). "')";
1237        }else{
1238            $count_area_seperator =":";
1239        }
1240
1241        $countdownClassOne = '';
1242        $countdownClassTwo = '';
1243        if($settings['htmega_count_style'] == 'flip'){
1244            $countdownClassOne = 'htmega-flash-flip-countdown-timer';
1245            $countdownClassTwo = 'ht-countdown ht-countdown-flip';
1246        }else{
1247            $countdownClassOne = 'htmega-countbox';
1248            $countdownClassTwo = '';
1249        }
1250
1251        ?>
1252            <div <?php echo $this->get_render_attribute_string( 'countdown_wrapper_attr' ); ?> >
1253                <div class="htmega-box-timer">
1254                    <div class="<?php echo esc_attr( $countdownClassOne ) ?>">
1255                        <?php
1256                            echo '<div class="'.esc_attr( $countdownClassTwo ).'"data-countdown=\'' . esc_attr( htmlspecialchars( wp_json_encode( $data_options ) ) ) . '\' ></div>';
1257                        ?>
1258                       
1259                        <?php if( $settings['show_event_list'] == 'yes' && $settings['event_id'] != 0 ):?>
1260                            <div class="htmega_event_button">
1261                                <a class="elementor-button" href="<?php echo esc_url( get_permalink( $settings['event_id'] ) );?>">
1262                                    <?php
1263                                        if( !empty( $settings['button_icon']['value'] ) ){
1264                                            echo HTMega_Icon_manager::render_icon( $settings['button_icon'], [ 'aria-hidden' => 'true' ] );
1265                                        } 
1266                                        if( !empty( $settings['button_text'] ) ){
1267                                            echo wp_kses_post( $settings['button_text'] );
1268                                        }
1269                                    ?>
1270                                </a>
1271                            </div>
1272                        <?php endif;?>
1273                    </div>
1274                </div>
1275
1276            </div>
1277
1278            <?php if($settings['counter_separator'] == 'yes'): ?>
1279                <style><?php echo esc_html( '.'.$sectionid ) ?> .htmega-countbox .ht-count::before{ content: <?php echo htmega_kses_desc($count_area_seperator) ?>;}</style>
1280           <?php endif;
1281    }
1282
1283}
Note: See TracBrowser for help on using the repository browser.