PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.6.2
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.6.2
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / elementor / modules / optin / fields / date.php

date.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.6.2, at includes/elementor/modules/optin/fields/date.php

248 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || die();
4
5 class Sellkit_Elementor_Optin_Field_Date extends Sellkit_Elementor_Optin_Field_Base {
6
7 public static function get_field_type() {
8 return 'date';
9 }
10
11 public function get_input_type() {
12 return $this->field['native_html5'] ? 'date' : '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 $localization = $this->field['localization'];
31
32 if ( 'yes' === $localization ) {
33 $locale = $this->date_localization();
34 $this->load_localize_script( $locale );
35 $this->widget->add_render_attribute( 'field-' . $this->get_id(), 'data-locale', $locale );
36 }
37
38 $this->widget->add_render_attribute( 'field-' . $this->get_id(), [
39 $this->field['native_html5'] ? 'min' : 'data-min-date' => $this->field['min_date'],
40 $this->field['native_html5'] ? 'max' : 'data-max-date' => $this->field['max_date'],
41 ] );
42 }
43
44 public function render_content() {
45 $attrs = $this->widget->get_render_attribute_string( 'field-' . $this->get_id() );
46
47 ?>
48 <input <?php echo $attrs; ?>>
49 <?php
50 }
51
52 public static function get_additional_controls() {
53 $commons = parent::get_common_controls();
54
55 return [
56 'label' => $commons['label'],
57 'field_value' => $commons['field_value'],
58 'placeholder' => $commons['placeholder'],
59 'min_date' => [
60 'label' => esc_html__( 'Min Date', 'sellkit' ),
61 'type' => 'date_time',
62 'label_block' => false,
63 'conditions' => [ 'terms' => [ parent::get_type_condition() ] ],
64 'picker_options' => [
65 'enableTime' => false,
66 'locale' => [
67 'firstDayOfWeek' => 1,
68 ],
69 ],
70 ],
71 'max_date' => [
72 'label' => esc_html__( 'Max Date', 'sellkit' ),
73 'type' => 'date_time',
74 'label_block' => false,
75 'conditions' => [ 'terms' => [ parent::get_type_condition() ] ],
76 'picker_options' => [
77 'enableTime' => false,
78 'locale' => [
79 'firstDayOfWeek' => 1,
80 ],
81 ],
82 ],
83 'localization' => [
84 'label' => esc_html__( 'Localization', 'sellkit' ),
85 'type' => 'switcher',
86 'return_value' => 'yes',
87 'conditions' => [ 'terms' => [ parent::get_type_condition() ] ],
88 ],
89 'native_html5' => [
90 'label' => esc_html__( 'Native HTML5', 'sellkit' ),
91 'type' => 'switcher',
92 'return_value' => 'true',
93 'conditions' => [ 'terms' => [ parent::get_type_condition() ] ],
94 ],
95 'required' => $commons['required'],
96 'width_responsive' => $commons['width_responsive'],
97 ];
98 }
99
100 private function date_localization() {
101 $wp_locale = get_locale();
102
103 $locales = [
104 'af' => '', // 'Afrikaans'
105 'ar' => 'ar', // 'Arabic'
106 'ary' => 'ar', // 'Moroccan Arabic'
107 'as' => '', // 'Assamese'
108 'azb' => 'az', // 'South Azerbaijani'
109 'az' => 'az', // 'Azerbaijani'
110 'bel' => 'be', // 'Belarusian'
111 'bg_BG' => 'bg', // 'Bulgarian'
112 'bn_BD' => 'bn', // 'Bengali (Bangladesh)'
113 'bo' => '', // 'Tibetan'
114 'bs_BA' => 'bs', // 'Bosnian'
115 'ca' => 'cat', // 'Catalan'
116 'ceb' => '', // 'Cebuano'
117 'cs_CZ' => 'cs', // 'Czech'
118 'cy' => 'cy', // 'Welsh'
119 'da_DK' => 'da', // 'Danish'
120 'de_CH_informal' => 'de', // 'German (Switzerland, Informal)'
121 'de_CH' => 'de', // 'German (Switzerland)'
122 'de_DE' => 'de', // 'German'
123 'de_DE_formal' => 'de', // 'German (Formal)'
124 'de_AT' => 'de', // 'German (Austria)'
125 'dzo' => '', // 'Dzongkha'
126 'el' => 'gr', // 'Greek'
127 'en_GB' => 'en', // 'English (UK)'
128 'en_AU' => 'en', // 'English (Australia)'
129 'en_CA' => 'en', // 'English (Canada)'
130 'en_ZA' => 'en', // 'English (South Africa)'
131 'en_NZ' => 'en', // 'English (New Zealand)'
132 'eo' => 'eo', // 'Esperanto'
133 'es_CL' => 'es', // 'Spanish (Chile)'
134 'es_ES' => 'es', // 'Spanish (Spain)'
135 'es_MX' => 'es', // 'Spanish (Mexico)'
136 'es_GT' => 'es', // 'Spanish (Guatemala)'
137 'es_CR' => 'es', // 'Spanish (Costa Rica)'
138 'es_CO' => 'es', // 'Spanish (Colombia)'
139 'es_PE' => 'es', // 'Spanish (Peru)'
140 'es_VE' => 'es', // 'Spanish (Venezuela)'
141 'es_AR' => 'es', // 'Spanish (Argentina)'
142 'et' => 'et', // 'Estonian'
143 'eu' => 'es', // 'Basque'
144 'fa_IR' => 'fa', // 'Persian'
145 'fi' => 'fi', // 'Finnish'
146 'fr_CA' => 'fr', // 'French (Canada)'
147 'fr_FR' => 'fr', // 'French (France)'
148 'fr_BE' => 'fr', // 'French (Belgium)'
149 'fur' => '', // 'Friulian'
150 'gd' => 'ga', // 'Scottish Gaelic'
151 'gl_ES' => 'es', // 'Galician'
152 'gu' => '', // 'Gujarati'
153 'haz' => '', // 'Hazaragi'
154 'he_IL' => 'he', // 'Hebrew'
155 'hi_IN' => 'hi', // 'Hindi'
156 'hr' => 'hr', // 'Croatian'
157 'hsb' => '', // 'Upper Sorbian'
158 'hu_HU' => 'hu', // 'Hungarian'
159 'hy' => '', // 'Armenian'
160 'id_ID' => 'id', // 'Indonesian'
161 'is_IS' => 'is', // 'Icelandic'
162 'it_IT' => 'it', // 'Italian'
163 'ja' => 'ja', // 'Japanese'
164 'jv_ID' => '', // 'Javanese'
165 'ka_GE' => 'ka', // 'Georgian'
166 'kab' => '', // 'Kabyle'
167 'kk' => 'kz', // 'Kazakh'
168 'km' => 'km', // 'Khmer'
169 'kn' => '', // 'Kannada'
170 'ko_KR' => 'ko', // 'Korean'
171 'ckb' => '', // 'Kurdish (Sorani)'
172 'lo' => '', // 'Lao'
173 'lt_LT' => 'lt', // 'Lithuanian'
174 'lv' => 'lv', // 'Latvian'
175 'mk_MK' => 'mk', // 'Macedonian'
176 'ml_IN' => '', // 'Malayalam'
177 'mn' => 'mn', // 'Mongolian'
178 'mr' => '', // 'Marathi'
179 'ms_MY' => 'ms', // 'Malay'
180 'my_MM' => 'my', // 'Myanmar (Burmese)'
181 'nb_NO' => 'no', // 'Norwegian (Bokmål)'
182 'ne_NP' => '', // 'Nepali'
183 'nl_NL' => 'nl', // 'Dutch'
184 'nl_NL_formal' => 'nl', // 'Dutch (Formal)'
185 'nl_BE' => 'nl', // 'Dutch (Belgium)'
186 'nn_NO' => 'no', // 'Norwegian (Nynorsk)'
187 'oci' => '', // 'Occitan'
188 'pa_IN' => 'pa', // 'Punjabi'
189 'pl_PL' => 'pl', // 'Polish'
190 'ps' => '', // 'Pashto'
191 'pt_BR' => 'pt', // 'Portuguese (Brazil)'
192 'pt_AO' => 'pt', // 'Portuguese (Angola)'
193 'pt_PT' => 'pt', // 'Portuguese (Portugal)'
194 'pt_PT_ao90' => 'pt', // 'Portuguese (Portugal, AO90)'
195 'rhg' => '', // 'Rohingya'
196 'ro_RO' => 'ro', // 'Romanian'
197 'ru_RU' => 'ru', // 'Russian'
198 'sah' => '', // 'Sakha'
199 'si_LK' => 'si', // 'Sinhala'
200 'sk_SK' => 'sk', // 'Slovak'
201 'skr' => '', // 'Saraiki'
202 'sl_SI' => 'sl', // 'Slovenian'
203 'sq' => 'sq', // 'Albanian'
204 'sr_RS' => 'sr', // 'Serbian'
205 'sv_SE' => 'sv', // 'Swedish'
206 'sw' => '', // 'Swahili'
207 'szl' => '', // 'Silesian'
208 'ta_IN' => '', // 'Tamil'
209 'te' => '', // 'Telugu'
210 'th' => 'th', // 'Thai'
211 'tl' => '', // 'Tagalog'
212 'tr_TR' => 'tr', // 'Turkish'
213 'tt_RU' => '', // 'Tatar'
214 'tah' => '', // 'Tahitian'
215 'ug_CN' => '', // 'Uighur'
216 'uk' => 'uk', // 'Ukrainian'
217 'ur' => '', // 'Urdu'
218 'uz_UZ' => '', // 'Uzbek'
219 'vi' => 'vn', // 'Vietnamese'
220 'zh_HK' => 'zh', // 'Chinese (Hong Kong)'
221 'zh_TW' => 'zh-tw', // 'Chinese (Taiwan)'
222 'zh_CN' => 'zh', // 'Chinese (China)'
223 ];
224
225 $result = array_key_exists( $wp_locale, $locales ) ? $locales[ $wp_locale ] : 'default';
226
227 if ( 'en' === $result || '' === $result ) {
228 $result = 'default';
229 }
230
231 return $result;
232 }
233
234 private function load_localize_script( $locale ) {
235 if ( 'default' === $locale ) {
236 return;
237 }
238
239 wp_enqueue_script( 'sellkit_flatpickr_localize',
240 sellkit()->plugin_url() . 'assets/lib/flatpickr-locale/' . $locale . '.js',
241 [ 'flatpickr' ],
242 '4.1.4',
243 true
244 );
245 }
246
247 }
248