breadcrumbs.php
6 months ago
copyright.php
6 months ago
current-time.php
6 months ago
logo.php
6 months ago
menu.php
6 months ago
modern-search.php
6 months ago
search.php
6 months ago
select.php
6 months ago
shopping-cart.php
6 months ago
site-title.php
6 months ago
current-time.php
225 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements\Theme_Elements; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Group_Control_Typography; |
| 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 9 | use Elementor\Group_Control_Text_Shadow; |
| 10 | |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly. |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Elementor 'Current_Time' widget. |
| 18 | * |
| 19 | * Elementor widget that displays an 'Current_Time'. |
| 20 | * |
| 21 | * @since 1.0.0 |
| 22 | */ |
| 23 | class Current_Time extends Widget_Base { |
| 24 | |
| 25 | /** |
| 26 | * Get widget name. |
| 27 | * |
| 28 | * Retrieve 'Current_Time' widget name. |
| 29 | * |
| 30 | * @since 1.0.0 |
| 31 | * @access public |
| 32 | * |
| 33 | * @return string Widget name. |
| 34 | */ |
| 35 | public function get_name() { |
| 36 | return 'aux_current_time'; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get widget title. |
| 41 | * |
| 42 | * Retrieve 'Current_Time' widget title. |
| 43 | * |
| 44 | * @since 1.0.0 |
| 45 | * @access public |
| 46 | * |
| 47 | * @return string Widget title. |
| 48 | */ |
| 49 | public function get_title() { |
| 50 | return __('Current Time', 'auxin-elements' ); |
| 51 | } |
| 52 | |
| 53 | public function has_widget_inner_wrapper(): bool { |
| 54 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * Get widget icon. |
| 60 | * |
| 61 | * Retrieve 'Current_Time' widget icon. |
| 62 | * |
| 63 | * @since 1.0.0 |
| 64 | * @access public |
| 65 | * |
| 66 | * @return string Widget icon. |
| 67 | */ |
| 68 | public function get_icon() { |
| 69 | return 'eicon-date auxin-badge'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get widget categories. |
| 74 | * |
| 75 | * Retrieve 'Current_Time' widget icon. |
| 76 | * |
| 77 | * @since 1.0.0 |
| 78 | * @access public |
| 79 | * |
| 80 | * @return string Widget icon. |
| 81 | */ |
| 82 | public function get_categories() { |
| 83 | return array( 'auxin-core', 'auxin-theme-elements' ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Register 'Current_Time' widget controls. |
| 88 | * |
| 89 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 90 | * |
| 91 | * @since 1.0.0 |
| 92 | * @access protected |
| 93 | */ |
| 94 | protected function register_controls() { |
| 95 | |
| 96 | /*-----------------------------------------------------------------------------------*/ |
| 97 | /* button_section |
| 98 | /*-----------------------------------------------------------------------------------*/ |
| 99 | |
| 100 | $this->start_controls_section( |
| 101 | 'general', |
| 102 | array( |
| 103 | 'label' => __('General', 'auxin-elements' ), |
| 104 | ) |
| 105 | ); |
| 106 | |
| 107 | $this->add_control( |
| 108 | 'type', |
| 109 | array( |
| 110 | 'label' => __('Type of time', 'auxin-elements'), |
| 111 | 'type' => Controls_Manager::SELECT, |
| 112 | 'default' => 'custom', |
| 113 | 'options' => array( |
| 114 | 'custom' => __('Custom' , 'auxin-elements' ), |
| 115 | 'mysql' => __('MySql' , 'auxin-elements' ), |
| 116 | 'timestamp' => __('TimeStamp' , 'auxin-elements' ) |
| 117 | ) |
| 118 | ) |
| 119 | ); |
| 120 | |
| 121 | $this->add_control( |
| 122 | 'date_format', |
| 123 | array( |
| 124 | 'label' => __('Date Format String','auxin-elements' ), |
| 125 | 'type' => Controls_Manager::TEXT, |
| 126 | 'default' => get_option( 'date_format' ), |
| 127 | 'condition' => array( |
| 128 | 'type' => array('custom'), |
| 129 | ) |
| 130 | ) |
| 131 | ); |
| 132 | |
| 133 | $this->add_responsive_control( |
| 134 | 'align', |
| 135 | array( |
| 136 | 'label' => __('Align','auxin-elements'), |
| 137 | 'type' => Controls_Manager::CHOOSE, |
| 138 | 'options' => array( |
| 139 | 'left' => array( |
| 140 | 'title' => __( 'Left', 'auxin-elements' ), |
| 141 | 'icon' => 'eicon-text-align-left', |
| 142 | ), |
| 143 | 'center' => array( |
| 144 | 'title' => __( 'Center', 'auxin-elements' ), |
| 145 | 'icon' => 'eicon-text-align-center', |
| 146 | ), |
| 147 | 'right' => array( |
| 148 | 'title' => __( 'Right', 'auxin-elements' ), |
| 149 | 'icon' => 'eicon-text-align-right', |
| 150 | ), |
| 151 | ), |
| 152 | 'toggle' => true, |
| 153 | 'selectors' => array( |
| 154 | '{{WRAPPER}}' => 'text-align: {{VALUE}}', |
| 155 | ) |
| 156 | ) |
| 157 | ); |
| 158 | |
| 159 | $this->end_controls_section(); |
| 160 | |
| 161 | /*-----------------------------------------------------------------------------------*/ |
| 162 | /* style |
| 163 | /*-----------------------------------------------------------------------------------*/ |
| 164 | |
| 165 | $this->start_controls_section( |
| 166 | 'text_section', |
| 167 | array( |
| 168 | 'label' => __('Text', 'auxin-elements' ), |
| 169 | 'tab' => Controls_Manager::TAB_STYLE, |
| 170 | ) |
| 171 | ); |
| 172 | |
| 173 | |
| 174 | $this->add_control( |
| 175 | 'text_color', |
| 176 | array( |
| 177 | 'label' => __( 'Color', 'auxin-elements' ), |
| 178 | 'type' => Controls_Manager::COLOR, |
| 179 | 'selectors' => array( |
| 180 | '{{WRAPPER}} .aux-current-time' => 'color: {{VALUE}};', |
| 181 | ) |
| 182 | ) |
| 183 | ); |
| 184 | |
| 185 | $this->add_group_control( |
| 186 | Group_Control_Text_Shadow::get_type(), |
| 187 | array( |
| 188 | 'name' => 'text_shadow', |
| 189 | 'label' => __( 'Text Shadow', 'auxin-elements' ), |
| 190 | 'selector' => '{{WRAPPER}} .aux-current-time', |
| 191 | ) |
| 192 | ); |
| 193 | |
| 194 | $this->add_group_control( |
| 195 | Group_Control_Typography::get_type(), |
| 196 | array( |
| 197 | 'name' => 'text_typography', |
| 198 | 'global' => [ |
| 199 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 200 | ], |
| 201 | 'selector' => '{{WRAPPER}} .aux-current-time' |
| 202 | ) |
| 203 | ); |
| 204 | |
| 205 | $this->end_controls_section(); |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Render image box widget output on the frontend. |
| 210 | * |
| 211 | * Written in PHP and used to generate the final HTML. |
| 212 | * |
| 213 | * @since 1.0.0 |
| 214 | * @access protected |
| 215 | */ |
| 216 | protected function render() { |
| 217 | |
| 218 | $settings = $this->get_settings_for_display(); |
| 219 | $type = $settings['type'] === 'custom' ? $settings['date_format'] : $settings['type']; |
| 220 | |
| 221 | echo sprintf( '<div class="aux-current-time">%s</div>', current_time( esc_html( $type ) ) ); |
| 222 | } |
| 223 | |
| 224 | } |
| 225 |