breadcrumbs.php
6 years ago
copyright.php
6 years ago
current-time.php
6 years ago
logo.php
6 years ago
menu.php
6 years ago
modern-search.php
6 years ago
search.php
6 years ago
shopping-cart.php
6 years ago
site-title.php
6 years ago
current-time.php
218 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\Scheme_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 | /** |
| 54 | * Get widget icon. |
| 55 | * |
| 56 | * Retrieve 'Current_Time' widget icon. |
| 57 | * |
| 58 | * @since 1.0.0 |
| 59 | * @access public |
| 60 | * |
| 61 | * @return string Widget icon. |
| 62 | */ |
| 63 | public function get_icon() { |
| 64 | return 'eicon-date auxin-badge'; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Get widget categories. |
| 69 | * |
| 70 | * Retrieve 'Current_Time' widget icon. |
| 71 | * |
| 72 | * @since 1.0.0 |
| 73 | * @access public |
| 74 | * |
| 75 | * @return string Widget icon. |
| 76 | */ |
| 77 | public function get_categories() { |
| 78 | return array( 'auxin-core', 'auxin-theme-elements' ); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Register 'Current_Time' widget controls. |
| 83 | * |
| 84 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 85 | * |
| 86 | * @since 1.0.0 |
| 87 | * @access protected |
| 88 | */ |
| 89 | protected function _register_controls() { |
| 90 | |
| 91 | /*-----------------------------------------------------------------------------------*/ |
| 92 | /* button_section |
| 93 | /*-----------------------------------------------------------------------------------*/ |
| 94 | |
| 95 | $this->start_controls_section( |
| 96 | 'general', |
| 97 | array( |
| 98 | 'label' => __('General', 'auxin-elements' ), |
| 99 | ) |
| 100 | ); |
| 101 | |
| 102 | $this->add_control( |
| 103 | 'type', |
| 104 | array( |
| 105 | 'label' => __('Type of time', 'auxin-elements'), |
| 106 | 'type' => Controls_Manager::SELECT, |
| 107 | 'default' => 'custom', |
| 108 | 'options' => array( |
| 109 | 'custom' => __('Custom' , 'auxin-elements' ), |
| 110 | 'mysql' => __('MySql' , 'auxin-elements' ), |
| 111 | 'timestamp' => __('TimeStamp' , 'auxin-elements' ) |
| 112 | ) |
| 113 | ) |
| 114 | ); |
| 115 | |
| 116 | $this->add_control( |
| 117 | 'date_format', |
| 118 | array( |
| 119 | 'label' => __('Date Format String','auxin-elements' ), |
| 120 | 'type' => Controls_Manager::TEXT, |
| 121 | 'default' => get_option( 'date_format' ), |
| 122 | 'condition' => array( |
| 123 | 'type' => array('custom'), |
| 124 | ) |
| 125 | ) |
| 126 | ); |
| 127 | |
| 128 | $this->add_responsive_control( |
| 129 | 'align', |
| 130 | array( |
| 131 | 'label' => __('Align','auxin-elements'), |
| 132 | 'type' => Controls_Manager::CHOOSE, |
| 133 | 'options' => array( |
| 134 | 'left' => array( |
| 135 | 'title' => __( 'Left', 'auxin-elements' ), |
| 136 | 'icon' => 'fa fa-align-left', |
| 137 | ), |
| 138 | 'center' => array( |
| 139 | 'title' => __( 'Center', 'auxin-elements' ), |
| 140 | 'icon' => 'fa fa-align-center', |
| 141 | ), |
| 142 | 'right' => array( |
| 143 | 'title' => __( 'Right', 'auxin-elements' ), |
| 144 | 'icon' => 'fa fa-align-right', |
| 145 | ), |
| 146 | ), |
| 147 | 'toggle' => true, |
| 148 | 'selectors' => array( |
| 149 | '{{WRAPPER}}' => 'text-align: {{VALUE}}', |
| 150 | ) |
| 151 | ) |
| 152 | ); |
| 153 | |
| 154 | $this->end_controls_section(); |
| 155 | |
| 156 | /*-----------------------------------------------------------------------------------*/ |
| 157 | /* style |
| 158 | /*-----------------------------------------------------------------------------------*/ |
| 159 | |
| 160 | $this->start_controls_section( |
| 161 | 'text_section', |
| 162 | array( |
| 163 | 'label' => __('Text', 'auxin-elements' ), |
| 164 | 'tab' => Controls_Manager::TAB_STYLE, |
| 165 | ) |
| 166 | ); |
| 167 | |
| 168 | |
| 169 | $this->add_control( |
| 170 | 'text_color', |
| 171 | array( |
| 172 | 'label' => __( 'Color', 'auxin-elements' ), |
| 173 | 'type' => Controls_Manager::COLOR, |
| 174 | 'selectors' => array( |
| 175 | '{{WRAPPER}} .aux-current-time' => 'color: {{VALUE}};', |
| 176 | ) |
| 177 | ) |
| 178 | ); |
| 179 | |
| 180 | $this->add_group_control( |
| 181 | Group_Control_Text_Shadow::get_type(), |
| 182 | array( |
| 183 | 'name' => 'text_shadow', |
| 184 | 'label' => __( 'Text Shadow', 'auxin-elements' ), |
| 185 | 'selector' => '{{WRAPPER}} .aux-current-time', |
| 186 | ) |
| 187 | ); |
| 188 | |
| 189 | $this->add_group_control( |
| 190 | Group_Control_Typography::get_type(), |
| 191 | array( |
| 192 | 'name' => 'text_typography', |
| 193 | 'scheme' => Scheme_Typography::TYPOGRAPHY_1, |
| 194 | 'selector' => '{{WRAPPER}} .aux-current-time' |
| 195 | ) |
| 196 | ); |
| 197 | |
| 198 | $this->end_controls_section(); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Render image box widget output on the frontend. |
| 203 | * |
| 204 | * Written in PHP and used to generate the final HTML. |
| 205 | * |
| 206 | * @since 1.0.0 |
| 207 | * @access protected |
| 208 | */ |
| 209 | protected function render() { |
| 210 | |
| 211 | $settings = $this->get_settings_for_display(); |
| 212 | $type = $settings['type'] === 'custom' ? $settings['date_format'] : $settings['type']; |
| 213 | |
| 214 | echo sprintf( '<div class="aux-current-time">%s</div>', current_time( esc_html( $type ) ) ); |
| 215 | } |
| 216 | |
| 217 | } |
| 218 |