PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.0.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.0.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / addons / dynamic / ma-current-time / ma-current-time.php

ma-current-time.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.0.9, at addons/dynamic/ma-current-time/ma-current-time.php

163 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Addons;
4
5 // Elementor Classes
6 use MasterAddons\Inc\Classes\Base\Master_Widget;
7 use \Elementor\Controls_Manager;
8 use \Elementor\Group_Control_Typography;
9 use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10 use \Elementor\Group_Control_Text_Shadow;
11
12 use MasterAddons\Inc\Classes\Helper;
13 use MasterAddons\Inc\Admin\Config;
14
15 /**
16 * Author Name: Liton Arefin
17 * Author URL : https: //jeweltheme.com
18 * Date : 02/04/2020
19 */
20
21 if (!defined('ABSPATH')) exit; // If this file is called directly, abort.
22
23 class Current_Time extends Master_Widget
24 {
25 use \MasterAddons\Inc\Traits\Widget_Notice;
26 use \MasterAddons\Inc\Traits\Widget_Assets_Trait;
27
28 public function get_name()
29 {
30 return 'ma-el-current-time';
31 }
32
33 public function get_title()
34 {
35 return esc_html__('Current Time', 'master-addons' );
36 }
37
38 public function get_icon()
39 {
40 return 'jltma-icon ' . Config::get_addon_icon($this->get_name());
41 }
42
43 protected function register_controls()
44 {
45
46 /**
47 * Current Time
48 */
49 $this->start_controls_section(
50 'ma_el_current_time_content',
51 [
52 'label' => esc_html__('General', 'master-addons' ),
53 ]
54 );
55
56 $this->add_control(
57 'ma_el_current_time_type',
58 array(
59 'label' => __('Type of time', 'master-addons' ),
60 'type' => Controls_Manager::SELECT,
61 'default' => 'custom',
62 'options' => array(
63 'custom' => __('Custom', 'master-addons' ),
64 'mysql' => __('MySql', 'master-addons' ),
65 'timestamp' => __('TimeStamp', 'master-addons' )
66 )
67 )
68 );
69
70 $this->add_control(
71 'ma_el_current_time_date_format',
72 array(
73 'label' => __('Date Format String', 'master-addons' ),
74 'type' => Controls_Manager::TEXT,
75 'default' => get_option('date_format'),
76 'description' => '<span class="pro-feature"> <a href="' . esc_url_raw('https://wordpress.org/support/article/formatting-date-and-time/') . '" target="_blank">Date Time Format Examples </a> </span>',
77 'condition' => array(
78 'ma_el_current_time_type' => array('custom'),
79 )
80 )
81 );
82
83 $this->add_responsive_control(
84 'ma_el_current_time_date_alignment',
85 array(
86 'label' => __('Alignment', 'master-addons' ),
87 'type' => Controls_Manager::CHOOSE,
88 'options' => Helper::jltma_content_alignment(),
89 'toggle' => true,
90 'selectors' => array(
91 '{{WRAPPER}}' => 'text-align: {{VALUE}}',
92 )
93 )
94 );
95
96 $this->end_controls_section();
97
98 /*
99 * Style for Current Time
100 */
101 $this->start_controls_section(
102 'ma_el_current_time_style',
103 array(
104 'label' => __('Text', 'master-addons' ),
105 'tab' => Controls_Manager::TAB_STYLE,
106 )
107 );
108
109 $this->add_control(
110 'ma_el_current_time_text_color',
111 array(
112 'label' => __('Color', 'master-addons' ),
113 'type' => Controls_Manager::COLOR,
114 'selectors' => array(
115 '{{WRAPPER}} .jltma-current-time' => 'color: {{VALUE}};',
116 )
117 )
118 );
119
120 $this->add_group_control(
121 Group_Control_Text_Shadow::get_type(),
122 array(
123 'name' => 'ma_el_current_time_text_shadow',
124 'label' => __('Text Shadow', 'master-addons' ),
125 'selector' => '{{WRAPPER}} .jltma-current-time',
126 )
127 );
128
129 $this->add_group_control(
130 Group_Control_Typography::get_type(),
131 array(
132 'name' => 'ma_el_current_time_text_typography',
133 'global' => [
134 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
135 ],
136 'selector' => '{{WRAPPER}} .jltma-current-time'
137 )
138 );
139
140 $this->end_controls_section();
141
142 // Help Docs section (links from config.php)
143 $this->jltma_help_docs();
144
145 $this->upgrade_to_pro_message();
146
147 }
148
149 protected function render()
150 {
151 $settings = $this->get_settings_for_display();
152 $date_format = $settings['ma_el_current_time_date_format'];
153 $time_type = $settings['ma_el_current_time_type'];
154
155 if( $time_type === 'custom' ){
156 $date = date_i18n( $date_format, strtotime(current_time( $time_type) ) );
157 }else{
158 $date = current_time($time_type);
159 }
160 echo sprintf(__('<div class="jltma-current-time">%s</div>', 'master-addons' ), $date );
161 }
162 }
163