| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || die(); |
| 4 |
|
| 5 |
class Sellkit_Elementor_Optin_Field_Time extends Sellkit_Elementor_Optin_Field_Base { |
| 6 |
|
| 7 |
public static function get_field_type() { |
| 8 |
return 'time'; |
| 9 |
} |
| 10 |
|
| 11 |
public function get_input_type() { |
| 12 |
return $this->field['native_html5'] ? 'time' : 'text'; |
| 13 |
} |
| 14 |
|
| 15 |
public function get_class() { |
| 16 |
return 'sellkit-field flatpickr'; |
| 17 |
} |
| 18 |
|
| 19 |
public function get_style_depends() { |
| 20 |
return [ 'flatpickr' ]; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_script_depends() { |
| 24 |
return [ 'flatpickr' ]; |
| 25 |
} |
| 26 |
|
| 27 |
public function add_field_render_attribute() { |
| 28 |
parent::add_field_render_attribute(); |
| 29 |
|
| 30 |
$this->widget->add_render_attribute( 'field-' . $this->get_id(), [ |
| 31 |
$this->field['native_html5'] ? 'min' : 'data-min-time' => $this->field['min_time'], |
| 32 |
$this->field['native_html5'] ? 'max' : 'data-max-time' => $this->field['max_time'], |
| 33 |
'data-enable-time' => 'true', |
| 34 |
'data-no-calendar' => 'true', |
| 35 |
'data-time_24hr' => 'true', |
| 36 |
] ); |
| 37 |
} |
| 38 |
|
| 39 |
public function render_content() { |
| 40 |
?> |
| 41 |
<input <?php echo $this->widget->get_render_attribute_string( 'field-' . esc_attr( $this->get_id() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor-generated attributes. ?>> |
| 42 |
<?php |
| 43 |
} |
| 44 |
|
| 45 |
public static function get_additional_controls() { |
| 46 |
$commons = parent::get_common_controls(); |
| 47 |
|
| 48 |
return [ |
| 49 |
'label' => $commons['label'], |
| 50 |
'field_value' => $commons['field_value'], |
| 51 |
'placeholder' => $commons['placeholder'], |
| 52 |
'min_time' => [ |
| 53 |
'label' => esc_html__( 'Min Time', 'sellkit' ), |
| 54 |
'type' => 'date_time', |
| 55 |
'label_block' => false, |
| 56 |
'conditions' => [ 'terms' => [ parent::get_type_condition() ] ], |
| 57 |
'picker_options' => [ |
| 58 |
'enableTime' => true, |
| 59 |
'noCalendar' => true, |
| 60 |
'time_24hr' => true, |
| 61 |
], |
| 62 |
], |
| 63 |
'max_time' => [ |
| 64 |
'label' => esc_html__( 'Max Time', 'sellkit' ), |
| 65 |
'type' => 'date_time', |
| 66 |
'label_block' => false, |
| 67 |
'conditions' => [ 'terms' => [ parent::get_type_condition() ] ], |
| 68 |
'picker_options' => [ |
| 69 |
'enableTime' => true, |
| 70 |
'noCalendar' => true, |
| 71 |
'time_24hr' => true, |
| 72 |
], |
| 73 |
], |
| 74 |
'native_html5' => [ |
| 75 |
'label' => esc_html__( 'Native HTML5', 'sellkit' ), |
| 76 |
'type' => 'switcher', |
| 77 |
'return_value' => 'true', |
| 78 |
'conditions' => [ 'terms' => [ parent::get_type_condition() ] ], |
| 79 |
], |
| 80 |
'required' => $commons['required'], |
| 81 |
'width_responsive' => $commons['width_responsive'], |
| 82 |
]; |
| 83 |
} |
| 84 |
} |
| 85 |
|