Date and Time Picker Field - Version 2.1.4

Version Description

  • Fix for English Canadian locale which became Catalan, also fixes other en_, fr_ and de_* locale.
Download this release

Release Info

Developer PerS
Plugin Icon 128x128 Date and Time Picker Field
Version 2.1.4
Comparing to
See all releases

Code changes from version 2.1.3 to 2.1.4

acf-date-time-picker.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Advanced Custom Fields: Date and Time Picker
4
  * Plugin URI: https://github.com/soderlind/acf-field-date-time-picker
5
  * Description: Date and Time Picker field for Advanced Custom Fields
6
- * Version: 2.1.3
7
  * Author: Per Soderlind
8
  * Author URI: http://soderlind.no
9
  * License: GPLv2 or later
@@ -11,7 +11,7 @@
11
  * Text Domain: acf-field-date-time-picker
12
  * Domain Path: /languages
13
  */
14
- define( 'ACFFIELDDATETIMEPICKER_VERSION', '2.1.3' );
15
  /**
16
  * Class acfFieldDateTimePickerPlugin
17
  */
3
  * Plugin Name: Advanced Custom Fields: Date and Time Picker
4
  * Plugin URI: https://github.com/soderlind/acf-field-date-time-picker
5
  * Description: Date and Time Picker field for Advanced Custom Fields
6
+ * Version: 2.1.4
7
  * Author: Per Soderlind
8
  * Author URI: http://soderlind.no
9
  * License: GPLv2 or later
11
  * Text Domain: acf-field-date-time-picker
12
  * Domain Path: /languages
13
  */
14
+ define( 'ACFFIELDDATETIMEPICKER_VERSION', '2.1.4' );
15
  /**
16
  * Class acfFieldDateTimePickerPlugin
17
  */
date-time-picker-v3.php CHANGED
@@ -25,9 +25,8 @@ class ACFFieldDateTimePicker extends acf_Field {
25
  // set name / title
26
  $this->name = 'date_time_picker';
27
  $this->title = __( 'Date and Time Picker' );
28
- $this->domain = 'acf-field-date-time-picker';
29
  $this->defaults = array(
30
- 'label' => __( 'Choose Time', $this->domain ),
31
  'time_format' => 'hh:mm',
32
  'show_date' => 'true',
33
  'date_format' => 'yy-mm-dd',
@@ -113,7 +112,7 @@ class ACFFieldDateTimePicker extends acf_Field {
113
  ?>
114
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
115
  <td class="label">
116
- <label for=""><?php _e( 'Date and Time Picker?', $this->domain ); ?></label>
117
  </td>
118
  <td>
119
  <?php
@@ -123,8 +122,8 @@ class ACFFieldDateTimePicker extends acf_Field {
123
  'value' => $field['show_date'],
124
  'layout' => 'horizontal',
125
  'choices' => array(
126
- 'true' => __( 'Date and Time Picker', $this->domain ),
127
- 'false' => __( 'Time Picker', $this->domain ),
128
  ),
129
  ));
130
  ?>
@@ -132,8 +131,8 @@ class ACFFieldDateTimePicker extends acf_Field {
132
  </tr>
133
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
134
  <td class="label">
135
- <label><?php _e( 'Date Format', $this->domain ); ?></label>
136
- <p class="description"><?php _e( 'eg. mm/dd/yy. read more about', $this->domain ); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
137
  </td>
138
  <td>
139
  <?php
@@ -147,8 +146,8 @@ class ACFFieldDateTimePicker extends acf_Field {
147
  </tr>
148
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
149
  <td class="label">
150
- <label><?php _e( 'Time Format', $this->domain ); ?></label>
151
- <p class="description"><?php printf( __( 'eg. hh:mm. read more about <a href="%s" target="_blank">formatting time</a>', $this->domain ), 'http://trentrichardson.com/examples/timepicker/#tp-formatting' ); ?></p>
152
  </td>
153
  <td>
154
  <?php
@@ -162,7 +161,7 @@ class ACFFieldDateTimePicker extends acf_Field {
162
  </tr>
163
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
164
  <td class="label">
165
- <label for=""><?php _e( 'Display Week Number?', $this->domain ); ?></label>
166
  </td>
167
  <td>
168
  <?php
@@ -172,8 +171,8 @@ class ACFFieldDateTimePicker extends acf_Field {
172
  'value' => $field['show_week_number'],
173
  'layout' => 'horizontal',
174
  'choices' => array(
175
- 'true' => __( 'Yes', $this->domain ),
176
- 'false' => __( 'No', $this->domain ),
177
  ),
178
  ));
179
  ?>
@@ -181,7 +180,7 @@ class ACFFieldDateTimePicker extends acf_Field {
181
  </tr>
182
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
183
  <td class="label">
184
- <label for=""><?php _e( 'Time Picker Style?', $this->domain ); ?></label>
185
  </td>
186
  <td>
187
  <?php
@@ -191,8 +190,8 @@ class ACFFieldDateTimePicker extends acf_Field {
191
  'value' => $field['picker'],
192
  'layout' => 'horizontal',
193
  'choices' => array(
194
- 'slider' => __( 'Slider', $this->domain ),
195
- 'select' => __( 'Dropdown', $this->domain ),
196
  ),
197
  ));
198
  ?>
@@ -200,8 +199,8 @@ class ACFFieldDateTimePicker extends acf_Field {
200
  </tr>
201
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
202
  <td class="label">
203
- <label for=""><?php _e( 'Save as timestamp?', $this->domain ); ?></label>
204
- <p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "No" if you need a date and time format not supported by <a href="%s" target="_blank">strtotime</a>', $this->domain ), 'http://php.net/manual/en/function.strtotime.php' ); ?></p>
205
  </td>
206
  <td>
207
  <?php
@@ -211,8 +210,8 @@ class ACFFieldDateTimePicker extends acf_Field {
211
  'value' => $field['save_as_timestamp'],
212
  'layout' => 'horizontal',
213
  'choices' => array(
214
- 'true' => __( 'Yes', $this->domain ),
215
- 'false' => __( 'No', $this->domain ),
216
  ),
217
  ));
218
  ?>
@@ -220,8 +219,8 @@ class ACFFieldDateTimePicker extends acf_Field {
220
  </tr>
221
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
222
  <td class="label">
223
- <label for=""><?php _e( 'Get field as a timestamp?', $this->domain ); ?></label>
224
- <p class="description"><?php printf(__( 'Most users should leave this untouched, only set it to "Yes" if you need get the date and time field as a timestamp using <a href="%s" target="_blank">the_field()</a> or <a href="%s" target="_blank">get_field()</a> ', $this->domain ), 'http://www.advancedcustomfields.com/resources/functions/the_field/',
225
  'http://www.advancedcustomfields.com/resources/functions/get_field/'); ?></p>
226
  </td>
227
  <td>
@@ -232,8 +231,8 @@ class ACFFieldDateTimePicker extends acf_Field {
232
  'value' => $field['get_as_timestamp'],
233
  'layout' => 'horizontal',
234
  'choices' => array(
235
- 'true' => __( 'Yes', $this->domain ),
236
- 'false' => __( 'No', $this->domain ),
237
  ),
238
  ));
239
  ?>
@@ -431,18 +430,18 @@ class ACFFieldDateTimePicker extends acf_Field {
431
 
432
  if ( ! $has_locale && 'en' != $js_locale ) {
433
  $timepicker_locale = array(
434
- 'closeText' => __( 'Done', $this->domain ),
435
- 'currentText' => __( 'Today', $this->domain ),
436
- 'prevText' => __( 'Prev', $this->domain ),
437
- 'nextText' => __( 'Next', $this->domain ),
438
- 'monthStatus' => __( 'Show a different month', $this->domain ),
439
- 'weekHeader' => __( 'Wk', $this->domain ),
440
- 'timeText' => __( 'Time', $this->domain ),
441
- 'hourText' => __( 'Hour', $this->domain ),
442
- 'minuteText' => __( 'Minute', $this->domain ),
443
- 'secondText' => __( 'Second', $this->domain ),
444
- 'millisecText' => __( 'Millisecond', $this->domain ),
445
- 'timezoneText' => __( 'Time Zone', $this->domain ),
446
  'isRTL' => $wp_locale->is_rtl(),
447
  );
448
  }
@@ -486,7 +485,17 @@ class ACFFieldDateTimePicker extends acf_Field {
486
 
487
  if ( false !== strpos( $locale, '-' ) ) {
488
  $l = explode( '-', $locale );
489
- $pattern = array( '/' . $locale . '/', '/' . $l[0] . '/', '/' . $l[1] . '/' );
 
 
 
 
 
 
 
 
 
 
490
  } else {
491
  $pattern = array( '/' . $locale . '/' );
492
  }
25
  // set name / title
26
  $this->name = 'date_time_picker';
27
  $this->title = __( 'Date and Time Picker' );
 
28
  $this->defaults = array(
29
+ 'label' => __( 'Choose Time', 'acf-field-date-time-picker' ),
30
  'time_format' => 'hh:mm',
31
  'show_date' => 'true',
32
  'date_format' => 'yy-mm-dd',
112
  ?>
113
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
114
  <td class="label">
115
+ <label for=""><?php _e( 'Date and Time Picker?', 'acf-field-date-time-picker' ); ?></label>
116
  </td>
117
  <td>
118
  <?php
122
  'value' => $field['show_date'],
123
  'layout' => 'horizontal',
124
  'choices' => array(
125
+ 'true' => __( 'Date and Time Picker', 'acf-field-date-time-picker' ),
126
+ 'false' => __( 'Time Picker', 'acf-field-date-time-picker' ),
127
  ),
128
  ));
129
  ?>
131
  </tr>
132
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
133
  <td class="label">
134
+ <label><?php _e( 'Date Format', 'acf-field-date-time-picker' ); ?></label>
135
+ <p class="description"><?php _e( 'eg. mm/dd/yy. read more about', 'acf-field-date-time-picker' ); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
136
  </td>
137
  <td>
138
  <?php
146
  </tr>
147
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
148
  <td class="label">
149
+ <label><?php _e( 'Time Format', 'acf-field-date-time-picker' ); ?></label>
150
+ <p class="description"><?php printf( __( 'eg. hh:mm. read more about <a href="%s" target="_blank">formatting time</a>', 'acf-field-date-time-picker' ), 'http://trentrichardson.com/examples/timepicker/#tp-formatting' ); ?></p>
151
  </td>
152
  <td>
153
  <?php
161
  </tr>
162
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
163
  <td class="label">
164
+ <label for=""><?php _e( 'Display Week Number?', 'acf-field-date-time-picker' ); ?></label>
165
  </td>
166
  <td>
167
  <?php
171
  'value' => $field['show_week_number'],
172
  'layout' => 'horizontal',
173
  'choices' => array(
174
+ 'true' => __( 'Yes', 'acf-field-date-time-picker' ),
175
+ 'false' => __( 'No', 'acf-field-date-time-picker' ),
176
  ),
177
  ));
178
  ?>
180
  </tr>
181
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
182
  <td class="label">
183
+ <label for=""><?php _e( 'Time Picker Style?', 'acf-field-date-time-picker' ); ?></label>
184
  </td>
185
  <td>
186
  <?php
190
  'value' => $field['picker'],
191
  'layout' => 'horizontal',
192
  'choices' => array(
193
+ 'slider' => __( 'Slider', 'acf-field-date-time-picker' ),
194
+ 'select' => __( 'Dropdown', 'acf-field-date-time-picker' ),
195
  ),
196
  ));
197
  ?>
199
  </tr>
200
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
201
  <td class="label">
202
+ <label for=""><?php _e( 'Save as timestamp?', 'acf-field-date-time-picker' ); ?></label>
203
+ <p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "No" if you need a date and time format not supported by <a href="%s" target="_blank">strtotime</a>', 'acf-field-date-time-picker' ), 'http://php.net/manual/en/function.strtotime.php' ); ?></p>
204
  </td>
205
  <td>
206
  <?php
210
  'value' => $field['save_as_timestamp'],
211
  'layout' => 'horizontal',
212
  'choices' => array(
213
+ 'true' => __( 'Yes', 'acf-field-date-time-picker' ),
214
+ 'false' => __( 'No', 'acf-field-date-time-picker' ),
215
  ),
216
  ));
217
  ?>
219
  </tr>
220
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
221
  <td class="label">
222
+ <label for=""><?php _e( 'Get field as a timestamp?', 'acf-field-date-time-picker' ); ?></label>
223
+ <p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "Yes" if you need get the date and time field as a timestamp using <a href="%1$s" target="_blank">the_field()</a> or <a href="%2$s" target="_blank">get_field()</a> ', 'acf-field-date-time-picker' ), 'http://www.advancedcustomfields.com/resources/functions/the_field/',
224
  'http://www.advancedcustomfields.com/resources/functions/get_field/'); ?></p>
225
  </td>
226
  <td>
231
  'value' => $field['get_as_timestamp'],
232
  'layout' => 'horizontal',
233
  'choices' => array(
234
+ 'true' => __( 'Yes', 'acf-field-date-time-picker' ),
235
+ 'false' => __( 'No', 'acf-field-date-time-picker' ),
236
  ),
237
  ));
238
  ?>
430
 
431
  if ( ! $has_locale && 'en' != $js_locale ) {
432
  $timepicker_locale = array(
433
+ 'closeText' => __( 'Done', 'acf-field-date-time-picker' ),
434
+ 'currentText' => __( 'Today', 'acf-field-date-time-picker' ),
435
+ 'prevText' => __( 'Prev', 'acf-field-date-time-picker' ),
436
+ 'nextText' => __( 'Next', 'acf-field-date-time-picker' ),
437
+ 'monthStatus' => __( 'Show a different month', 'acf-field-date-time-picker' ),
438
+ 'weekHeader' => __( 'Wk', 'acf-field-date-time-picker' ),
439
+ 'timeText' => __( 'Time', 'acf-field-date-time-picker' ),
440
+ 'hourText' => __( 'Hour', 'acf-field-date-time-picker' ),
441
+ 'minuteText' => __( 'Minute', 'acf-field-date-time-picker' ),
442
+ 'secondText' => __( 'Second', 'acf-field-date-time-picker' ),
443
+ 'millisecText' => __( 'Millisecond', 'acf-field-date-time-picker' ),
444
+ 'timezoneText' => __( 'Time Zone', 'acf-field-date-time-picker' ),
445
  'isRTL' => $wp_locale->is_rtl(),
446
  );
447
  }
485
 
486
  if ( false !== strpos( $locale, '-' ) ) {
487
  $l = explode( '-', $locale );
488
+ switch ( $l[0] ) {
489
+ case 'en':
490
+ case 'fr':
491
+ case 'de':
492
+ $pattern = array( '/' . $l[0] . '/' );
493
+ break;
494
+
495
+ default:
496
+ $pattern = array( '/' . $l[1] . '/' );
497
+ break;
498
+ }
499
  } else {
500
  $pattern = array( '/' . $locale . '/' );
501
  }
date-time-picker-v4.php CHANGED
@@ -1,8 +1,7 @@
1
  <?php
2
 
3
  if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
4
- class ACFFieldDateTimePicker extends acf_field
5
- {
6
  // vars
7
  var $settings // will hold info such as dir / path
8
  , $defaults // will hold default field options
@@ -21,10 +20,9 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
21
  // vars
22
  $this->name = 'date_time_picker';
23
  $this->label = __( 'Date and Time Picker' );
24
- $this->category = __( 'jQuery', $this->domain ); // Basic, Content, Choice, etc
25
- $this->domain = 'acf-field-date-time-picker';
26
  $this->defaults = array(
27
- 'label' => __( 'Choose Time', $this->domain ),
28
  'time_format' => 'h:mm tt',
29
  'show_date' => 'true',
30
  'date_format' => 'm/d/y',
@@ -39,8 +37,8 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
39
 
40
  // settings
41
  $this->settings = array(
42
- 'path' => apply_filters( 'acf/helpers/get_path', __FILE__ ),
43
- 'dir' => apply_filters( 'acf/helpers/get_dir', __FILE__ ),
44
  'version' => ACFFIELDDATETIMEPICKER_VERSION,
45
  );
46
  }
@@ -64,18 +62,18 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
64
  ?>
65
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
66
  <td class="label">
67
- <label for=""><?php _e( 'Date and Time Picker?', $this->domain ); ?></label>
68
  </td>
69
  <td>
70
  <?php
71
- do_action('acf/create_field', array(
72
  'type' => 'radio',
73
  'name' => 'fields[' . $key . '][show_date]',
74
  'value' => $field['show_date'],
75
  'layout' => 'horizontal',
76
  'choices' => array(
77
- 'true' => __( 'Date and Time Picker', $this->domain ),
78
- 'false' => __( 'Time Picker', $this->domain ),
79
  ),
80
  ));
81
  ?>
@@ -83,12 +81,12 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
83
  </tr>
84
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
85
  <td class="label">
86
- <label><?php _e( 'Date Format', $this->domain ); ?></label>
87
- <p class="description"><?php printf( __( 'eg. mm/dd/yy. read more about <a href="%s" target="_blank">formatting date</a>', $this->domain ), 'http://docs.jquery.com/UI/Datepicker/formatDate' ); ?></p>
88
  </td>
89
  <td>
90
  <?php
91
- do_action('acf/create_field', array(
92
  'type' => 'text',
93
  'name' => 'fields[' . $key . '][date_format]',
94
  'value' => $field['date_format'],
@@ -114,12 +112,12 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
114
  </tr>
115
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
116
  <td class="label">
117
- <label><?php _e( 'Time Format', $this->domain ); ?></label>
118
- <p class="description"><?php printf( __( 'eg. hh:mm. read more about <a href="%s" target="_blank">formatting time</a>', $this->domain ), 'http://trentrichardson.com/examples/timepicker/#tp-formatting' ); ?></p>
119
  </td>
120
  <td>
121
  <?php
122
- do_action('acf/create_field', array(
123
  'type' => 'text',
124
  'name' => 'fields[' . $key . '][time_format]',
125
  'value' => $field['time_format'],
@@ -142,18 +140,18 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
142
  </tr>
143
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
144
  <td class="label">
145
- <label for=""><?php _e( 'Display Week Number?', $this->domain ); ?></label>
146
  </td>
147
  <td>
148
  <?php
149
- do_action('acf/create_field', array(
150
  'type' => 'radio',
151
  'name' => 'fields[' . $key . '][show_week_number]',
152
  'value' => $field['show_week_number'],
153
  'layout' => 'horizontal',
154
  'choices' => array(
155
- 'true' => __( 'Yes', $this->domain ),
156
- 'false' => __( 'No', $this->domain ),
157
  ),
158
  ));
159
  ?>
@@ -161,18 +159,18 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
161
  </tr>
162
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
163
  <td class="label">
164
- <label for=""><?php _e( 'Time Picker style?', $this->domain ); ?></label>
165
  </td>
166
  <td>
167
  <?php
168
- do_action('acf/create_field', array(
169
  'type' => 'radio',
170
  'name' => 'fields[' . $key . '][picker]',
171
  'value' => $field['picker'],
172
  'layout' => 'horizontal',
173
  'choices' => array(
174
- 'slider' => __( 'Slider', $this->domain ),
175
- 'select' => __( 'Dropdown', $this->domain ),
176
  ),
177
  ));
178
  ?>
@@ -180,19 +178,19 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
180
  </tr>
181
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
182
  <td class="label">
183
- <label for=""><?php _e( 'Save as timestamp?', $this->domain ); ?></label>
184
- <p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "No" if you need a date and time format not supported by <a href="%s" target="_blank">strtotime</a>', $this->domain ), 'http://php.net/manual/en/function.strtotime.php' ); ?></p>
185
  </td>
186
  <td>
187
  <?php
188
- do_action('acf/create_field', array(
189
  'type' => 'radio',
190
  'name' => 'fields[' . $key . '][save_as_timestamp]',
191
  'value' => $field['save_as_timestamp'],
192
  'layout' => 'horizontal',
193
  'choices' => array(
194
- 'true' => __( 'Yes', $this->domain ),
195
- 'false' => __( 'No', $this->domain ),
196
  ),
197
  ));
198
  ?>
@@ -200,20 +198,20 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
200
  </tr>
201
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
202
  <td class="label">
203
- <label for=""><?php _e( 'Get field as timestamp?', $this->domain ); ?></label>
204
- <p class="description"><?php printf(__( 'Most users should leave this untouched, only set it to "Yes" if you need get the date and time field as a timestamp using <a href="%s" target="_blank">the_field()</a> or <a href="%s" target="_blank">get_field()</a> ', $this->domain ), 'http://www.advancedcustomfields.com/resources/functions/the_field/',
205
  'http://www.advancedcustomfields.com/resources/functions/get_field/'); ?></p>
206
  </td>
207
  <td>
208
  <?php
209
- do_action('acf/create_field', array(
210
  'type' => 'radio',
211
  'name' => 'fields[' . $key . '][get_as_timestamp]',
212
  'value' => $field['get_as_timestamp'],
213
  'layout' => 'horizontal',
214
  'choices' => array(
215
- 'true' => __( 'Yes', $this->domain ),
216
- 'false' => __( 'No', $this->domain ),
217
  ),
218
  ));
219
  ?>
@@ -387,18 +385,18 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
387
 
388
  if ( ! $has_locale && 'en' != $js_locale ) {
389
  $timepicker_locale = array(
390
- 'closeText' => __( 'Done', $this->domain ),
391
- 'currentText' => __( 'Today', $this->domain ),
392
- 'prevText' => __( 'Prev', $this->domain ),
393
- 'nextText' => __( 'Next', $this->domain ),
394
- 'monthStatus' => __( 'Show a different month', $this->domain ),
395
- 'weekHeader' => __( 'Wk', $this->domain ),
396
- 'timeText' => __( 'Time', $this->domain ),
397
- 'hourText' => __( 'Hour', $this->domain ),
398
- 'minuteText' => __( 'Minute', $this->domain ),
399
- 'secondText' => __( 'Second', $this->domain ),
400
- 'millisecText' => __( 'Millisecond', $this->domain ),
401
- 'timezoneText' => __( 'Time Zone', $this->domain ),
402
  'isRTL' => $wp_locale->is_rtl(),
403
  );
404
  }
@@ -448,12 +446,25 @@ if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
448
 
449
  if ( false !== strpos( $locale, '-' ) ) {
450
  $l = explode( '-', $locale );
451
- $pattern = array( '/' . $locale . '/', '/' . $l[0] . '/', '/' . $l[1] . '/' );
 
 
 
 
 
 
 
 
 
 
 
452
  } else {
453
  $pattern = array( '/' . $locale . '/' );
454
  }
 
455
  $res = $this->ps_preg_filter( $pattern, '$0', $languages, -1, $count );
456
-
 
457
  return ($count) ? implode( '', $res ) : 'en';
458
  }
459
 
1
  <?php
2
 
3
  if ( ! class_exists( 'ACFFieldDateTimePicker' ) ) :
4
+ class ACFFieldDateTimePicker extends acf_field {
 
5
  // vars
6
  var $settings // will hold info such as dir / path
7
  , $defaults // will hold default field options
20
  // vars
21
  $this->name = 'date_time_picker';
22
  $this->label = __( 'Date and Time Picker' );
23
+ $this->category = __( 'jQuery', 'acf-field-date-time-picker' ); // Basic, Content, Choice, etc
 
24
  $this->defaults = array(
25
+ 'label' => __( 'Choose Time', 'acf-field-date-time-picker' ),
26
  'time_format' => 'h:mm tt',
27
  'show_date' => 'true',
28
  'date_format' => 'm/d/y',
37
 
38
  // settings
39
  $this->settings = array(
40
+ 'path' => apply_filters( 'acf/helpers/get_path', __FILE__ ), // @codingStandardsIgnoreLine
41
+ 'dir' => apply_filters( 'acf/helpers/get_dir', __FILE__ ), // @codingStandardsIgnoreLine
42
  'version' => ACFFIELDDATETIMEPICKER_VERSION,
43
  );
44
  }
62
  ?>
63
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_choice">
64
  <td class="label">
65
+ <label for=""><?php _e( 'Date and Time Picker?', 'acf-field-date-time-picker' ); ?></label>
66
  </td>
67
  <td>
68
  <?php
69
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
70
  'type' => 'radio',
71
  'name' => 'fields[' . $key . '][show_date]',
72
  'value' => $field['show_date'],
73
  'layout' => 'horizontal',
74
  'choices' => array(
75
+ 'true' => __( 'Date and Time Picker', 'acf-field-date-time-picker' ),
76
+ 'false' => __( 'Time Picker', 'acf-field-date-time-picker' ),
77
  ),
78
  ));
79
  ?>
81
  </tr>
82
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_dateformat">
83
  <td class="label">
84
+ <label><?php _e( 'Date Format', 'acf-field-date-time-picker' ); ?></label>
85
+ <p class="description"><?php printf( __( 'eg. mm/dd/yy. read more about <a href="%s" target="_blank">formatting date</a>', 'acf-field-date-time-picker' ), 'http://docs.jquery.com/UI/Datepicker/formatDate' ); ?></p>
86
  </td>
87
  <td>
88
  <?php
89
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
90
  'type' => 'text',
91
  'name' => 'fields[' . $key . '][date_format]',
92
  'value' => $field['date_format'],
112
  </tr>
113
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_timeformat">
114
  <td class="label">
115
+ <label><?php _e( 'Time Format', 'acf-field-date-time-picker' ); ?></label>
116
+ <p class="description"><?php printf( __( 'eg. hh:mm. read more about <a href="%s" target="_blank">formatting time</a>', 'acf-field-date-time-picker' ), 'http://trentrichardson.com/examples/timepicker/#tp-formatting' ); ?></p>
117
  </td>
118
  <td>
119
  <?php
120
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
121
  'type' => 'text',
122
  'name' => 'fields[' . $key . '][time_format]',
123
  'value' => $field['time_format'],
140
  </tr>
141
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
142
  <td class="label">
143
+ <label for=""><?php _e( 'Display Week Number?', 'acf-field-date-time-picker' ); ?></label>
144
  </td>
145
  <td>
146
  <?php
147
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
148
  'type' => 'radio',
149
  'name' => 'fields[' . $key . '][show_week_number]',
150
  'value' => $field['show_week_number'],
151
  'layout' => 'horizontal',
152
  'choices' => array(
153
+ 'true' => __( 'Yes', 'acf-field-date-time-picker' ),
154
+ 'false' => __( 'No', 'acf-field-date-time-picker' ),
155
  ),
156
  ));
157
  ?>
159
  </tr>
160
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
161
  <td class="label">
162
+ <label for=""><?php _e( 'Time Picker style?', 'acf-field-date-time-picker' ); ?></label>
163
  </td>
164
  <td>
165
  <?php
166
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
167
  'type' => 'radio',
168
  'name' => 'fields[' . $key . '][picker]',
169
  'value' => $field['picker'],
170
  'layout' => 'horizontal',
171
  'choices' => array(
172
+ 'slider' => __( 'Slider', 'acf-field-date-time-picker' ),
173
+ 'select' => __( 'Dropdown', 'acf-field-date-time-picker' ),
174
  ),
175
  ));
176
  ?>
178
  </tr>
179
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
180
  <td class="label">
181
+ <label for=""><?php _e( 'Save as timestamp?', 'acf-field-date-time-picker' ); ?></label>
182
+ <p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "No" if you need a date and time format not supported by <a href="%s" target="_blank">strtotime</a>', 'acf-field-date-time-picker' ), 'http://php.net/manual/en/function.strtotime.php' ); ?></p>
183
  </td>
184
  <td>
185
  <?php
186
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
187
  'type' => 'radio',
188
  'name' => 'fields[' . $key . '][save_as_timestamp]',
189
  'value' => $field['save_as_timestamp'],
190
  'layout' => 'horizontal',
191
  'choices' => array(
192
+ 'true' => __( 'Yes', 'acf-field-date-time-picker' ),
193
+ 'false' => __( 'No', 'acf-field-date-time-picker' ),
194
  ),
195
  ));
196
  ?>
198
  </tr>
199
  <tr class="field_option field_option_<?php echo $this->name; ?> timepicker_week_number">
200
  <td class="label">
201
+ <label for=""><?php _e( 'Get field as timestamp?', 'acf-field-date-time-picker' ); ?></label>
202
+ <p class="description"><?php printf( __( 'Most users should leave this untouched, only set it to "Yes" if you need get the date and time field as a timestamp using <a href="%1$s" target="_blank">the_field()</a> or <a href="%2$s" target="_blank">get_field()</a> ', 'acf-field-date-time-picker' ), 'http://www.advancedcustomfields.com/resources/functions/the_field/',
203
  'http://www.advancedcustomfields.com/resources/functions/get_field/'); ?></p>
204
  </td>
205
  <td>
206
  <?php
207
+ do_action('acf/create_field', array( // @codingStandardsIgnoreLine
208
  'type' => 'radio',
209
  'name' => 'fields[' . $key . '][get_as_timestamp]',
210
  'value' => $field['get_as_timestamp'],
211
  'layout' => 'horizontal',
212
  'choices' => array(
213
+ 'true' => __( 'Yes', 'acf-field-date-time-picker' ),
214
+ 'false' => __( 'No', 'acf-field-date-time-picker' ),
215
  ),
216
  ));
217
  ?>
385
 
386
  if ( ! $has_locale && 'en' != $js_locale ) {
387
  $timepicker_locale = array(
388
+ 'closeText' => __( 'Done', 'acf-field-date-time-picker' ),
389
+ 'currentText' => __( 'Today', 'acf-field-date-time-picker' ),
390
+ 'prevText' => __( 'Prev', 'acf-field-date-time-picker' ),
391
+ 'nextText' => __( 'Next', 'acf-field-date-time-picker' ),
392
+ 'monthStatus' => __( 'Show a different month', 'acf-field-date-time-picker' ),
393
+ 'weekHeader' => __( 'Wk', 'acf-field-date-time-picker' ),
394
+ 'timeText' => __( 'Time', 'acf-field-date-time-picker' ),
395
+ 'hourText' => __( 'Hour', 'acf-field-date-time-picker' ),
396
+ 'minuteText' => __( 'Minute', 'acf-field-date-time-picker' ),
397
+ 'secondText' => __( 'Second', 'acf-field-date-time-picker' ),
398
+ 'millisecText' => __( 'Millisecond', 'acf-field-date-time-picker' ),
399
+ 'timezoneText' => __( 'Time Zone', 'acf-field-date-time-picker' ),
400
  'isRTL' => $wp_locale->is_rtl(),
401
  );
402
  }
446
 
447
  if ( false !== strpos( $locale, '-' ) ) {
448
  $l = explode( '-', $locale );
449
+ // $pattern = array( '/' . $locale . '/', '/' . $l[0] . '/', '/' . $l[1] . '/' );
450
+ switch ($l[0]) {
451
+ case 'en':
452
+ case 'fr':
453
+ case 'de':
454
+ $pattern = array( '/' . $l[0] . '/' );
455
+ break;
456
+
457
+ default:
458
+ $pattern = array( '/' . $l[1] . '/' );
459
+ break;
460
+ }
461
  } else {
462
  $pattern = array( '/' . $locale . '/' );
463
  }
464
+ write_log( $pattern );
465
  $res = $this->ps_preg_filter( $pattern, '$0', $languages, -1, $count );
466
+ write_log('count ' . $count );
467
+ write_log( $res );
468
  return ($count) ? implode( '', $res ) : 'en';
469
  }
470
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://soderlind.no/donate/
4
  Tags: acf, custom field,datepicker,timepicker
5
  Requires at least: 3.6
6
  Tested up to: 4.7
7
- Stable tag: 2.1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -128,7 +128,8 @@ The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date]
128
 
129
 
130
  == Changelog ==
131
-
 
132
  = 2.1.3 =
133
  * Sorry, but 2.1.2 had unfinsihed code, please update to 2.1.3
134
  = 2.1.2 =
4
  Tags: acf, custom field,datepicker,timepicker
5
  Requires at least: 3.6
6
  Tested up to: 4.7
7
+ Stable tag: 2.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
128
 
129
 
130
  == Changelog ==
131
+ = 2.1.4 =
132
+ * Fix for English Canadian locale which became Catalan, also fixes other en_*, fr_* and de_* locale.
133
  = 2.1.3 =
134
  * Sorry, but 2.1.2 had unfinsihed code, please update to 2.1.3
135
  = 2.1.2 =