Date and Time Picker Field - Version 2.0.15.2

Version Description

Download this release

Release Info

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

Code changes from version 2.0.14 to 2.0.15.2

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.0.14
7
  Author: Per Soderlind
8
  Author URI: http://soderlind.no
9
  License: GPLv2 or later
@@ -27,6 +27,9 @@ class acf_field_date_time_picker_plugin
27
  {
28
  load_plugin_textdomain( 'acf-field-date-time-picker', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
29
 
 
 
 
30
  // version 4+
31
  add_action('acf/register_fields', array($this, 'register_fields'));
32
 
@@ -65,6 +68,12 @@ class acf_field_date_time_picker_plugin
65
  include_once('date_time_picker-v4.php');
66
  }
67
 
 
 
 
 
 
 
68
  }
69
 
70
  new acf_field_date_time_picker_plugin();
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.0.15.2
7
  Author: Per Soderlind
8
  Author URI: http://soderlind.no
9
  License: GPLv2 or later
27
  {
28
  load_plugin_textdomain( 'acf-field-date-time-picker', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
29
 
30
+ // version 5+
31
+ add_action('acf/include_field_types', array($this, 'include_field_types'));
32
+
33
  // version 4+
34
  add_action('acf/register_fields', array($this, 'register_fields'));
35
 
68
  include_once('date_time_picker-v4.php');
69
  }
70
 
71
+
72
+ function include_field_types()
73
+ {
74
+ include_once('date_time_picker-v5.php');
75
+ }
76
+
77
  }
78
 
79
  new acf_field_date_time_picker_plugin();
css/jquery-ui-timepicker-addon.css CHANGED
@@ -7,4 +7,5 @@
7
 
8
  .ui-timepicker-rtl{ direction: rtl; }
9
  .ui-timepicker-rtl dl { text-align: right; }
10
- .ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }
 
7
 
8
  .ui-timepicker-rtl{ direction: rtl; }
9
  .ui-timepicker-rtl dl { text-align: right; }
10
+ .ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }
11
+ .acf-ui-datepicker .ui-datepicker { display: none; }
date_time_picker-v5.php ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class acf_field_date_time_picker extends acf_field
4
+ {
5
+
6
+ /*
7
+ * __construct
8
+ *
9
+ * Set name / label needed for actions / filters
10
+ *
11
+ * @since 3.6
12
+ * @date 23/01/13
13
+ */
14
+
15
+ function __construct()
16
+ {
17
+ // vars
18
+ $this->name = 'date_time_picker';
19
+ $this->label = __('Date and Time Picker');
20
+ $this->category = __("jQuery", $this->domain); // Basic, Content, Choice, etc
21
+ $this->domain = 'acf-field-date-time-picker';
22
+ $this->defaults = array(
23
+ 'label' => __( 'Choose Time', $this->domain )
24
+ , 'time_format' => 'h:mm tt'
25
+ , 'show_date' => 'true'
26
+ , 'date_format' => 'm/d/y'
27
+ , 'show_week_number' => 'false'
28
+ , 'picker' => 'slider'
29
+ , 'save_as_timestamp' => 'true'
30
+ , 'get_as_timestamp' => 'false'
31
+ );
32
+
33
+ $this->version = '2.0.15';
34
+ $this->dir = plugin_dir_url( __FILE__ );
35
+ $this->path = plugin_dir_path(__FILE__);
36
+
37
+ // do not delete!
38
+ parent::__construct();
39
+ }
40
+
41
+
42
+ /*
43
+ * create_options()
44
+ *
45
+ * Create extra options for your field. This is rendered when editing a field.
46
+ * The value of $field['name'] can be used (like bellow) to save extra data to the $field
47
+ *
48
+ * @type action
49
+ * @since 3.6
50
+ * @date 23/01/13
51
+ *
52
+ * @param $field - an array holding all the field's data
53
+ */
54
+
55
+ function render_field_settings( $field )
56
+ {
57
+ $field = array_merge($this->defaults, $field);
58
+ $key = $field['name'];
59
+
60
+ acf_render_field_setting( $field, array(
61
+ 'type' => 'radio'
62
+ , 'label' => __( "Date and Time Picker?", $this->domain)
63
+ , 'name' => 'show_date'
64
+ , 'value' => $field['show_date']
65
+ , 'layout' => 'horizontal'
66
+ , 'choices' => array(
67
+ 'true' => __( 'Date and Time Picker', $this->domain )
68
+ , 'false' => __( 'Time Picker', $this->domain )
69
+ )
70
+ ) );
71
+
72
+ acf_render_field_setting( $field, array(
73
+ 'type' => 'text'
74
+ , 'label' => __( "Date Format", $this->domain )
75
+ , 'instructions' => sprintf(__("eg. mm/dd/yy. read more about <a href=\"%s\" target=\"_blank\">formatting date</a>", $this->domain ),"http://docs.jquery.com/UI/Datepicker/formatDate")
76
+ , 'name' => 'date_format'
77
+ , 'value' => $field['date_format']
78
+ ) );
79
+
80
+ acf_render_field_setting( $field, array(
81
+ 'type' => 'text'
82
+ , 'label' => __( "Time Format", $this->domain )
83
+ , 'instructions' => sprintf(__("eg. hh:mm. read more about <a href=\"%s\" target=\"_blank\">formatting time</a>", $this->domain ),"http://trentrichardson.com/examples/timepicker/#tp-formatting")
84
+ , 'name' => 'time_format'
85
+ , 'value' => $field['time_format']
86
+ ) );
87
+
88
+ acf_render_field_setting( $field, array(
89
+ 'type' => 'radio'
90
+ , 'label' => __( "Display Week Number?", $this->domain )
91
+ , 'name' => 'show_week_number'
92
+ , 'value' => $field['show_week_number']
93
+ , 'layout' => 'horizontal'
94
+ , 'choices' => array(
95
+ 'true' => __( 'Yes', $this->domain )
96
+ , 'false' => __( 'No', $this->domain )
97
+ )
98
+ ) );
99
+
100
+ acf_render_field_setting( $field, array(
101
+ 'type' => 'radio'
102
+ , 'label' => __( "Time Picker style?", $this->domain )
103
+ , 'name' => 'picker'
104
+ , 'value' => $field['picker']
105
+ , 'layout' => 'horizontal'
106
+ , 'choices' => array(
107
+ 'slider' => __( 'Slider', $this->domain )
108
+ , 'select' => __( 'Dropdown', $this->domain )
109
+ )
110
+ ) );
111
+
112
+ acf_render_field_setting( $field, array(
113
+ 'type' => 'radio'
114
+ , 'label' => __( "Save as timestamp?", $this->domain )
115
+ , 'instructions' => sprintf( __( "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" )
116
+ , 'name' => 'save_as_timestamp'
117
+ , 'value' => $field['save_as_timestamp']
118
+ , 'layout' => 'horizontal'
119
+ , 'choices' => array(
120
+ 'true' => __( 'Yes', $this->domain )
121
+ , 'false' => __( 'No', $this->domain )
122
+ )
123
+ ) );
124
+
125
+ acf_render_field_setting( $field, array(
126
+ 'type' => 'radio'
127
+ , 'label' => __( "Get field as timestamp?", $this->domain )
128
+ , 'instructions' => sprintf( __( "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/", "http://www.advancedcustomfields.com/resources/functions/get_field/" )
129
+ , 'name' => 'get_as_timestamp'
130
+ , 'value' => $field['get_as_timestamp']
131
+ , 'layout' => 'horizontal'
132
+ , 'choices' => array(
133
+ 'true' => __( 'Yes', $this->domain )
134
+ , 'false' => __( 'No', $this->domain )
135
+ )
136
+ ) );
137
+ }
138
+
139
+
140
+
141
+ /*
142
+ * create_field()
143
+ *
144
+ * Create the HTML interface for your field
145
+ *
146
+ * @param $field - an array holding all the field's data
147
+ *
148
+ * @type action
149
+ * @since 3.6
150
+ * @date 23/01/13
151
+ */
152
+
153
+ function render_field( $field ) {
154
+
155
+ if ( $field['show_date'] !== 'true' ) {
156
+ echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-time_format="' . $field['time_format'] . '" title="' . $field['label'] . '" />';
157
+ } else {
158
+ echo '<input type="text" value="' . $field['value'] . '" name="' . $field['name'] . '" class="ps_timepicker" value="" data-picker="' . $field['picker'] . '" data-date_format="' . $field['date_format'] . '" data-time_format="' . $field['time_format'] . '" data-show_week_number="' . $field['show_week_number'] . '" title="' . $field['label'] . '" />';
159
+ }
160
+ }
161
+
162
+ function format_value($value, $post_id, $field)
163
+ {
164
+ $field = array_merge($this->defaults, $field);
165
+
166
+ /*if ($value != '' && $field['save_as_timestamp'] == 'true' && $this->isValidTimeStamp($value)) {
167
+ if ( $field['show_date'] == 'true') {
168
+ $value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
169
+ } else {
170
+ $value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
171
+ }
172
+ }*/
173
+
174
+ if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) {
175
+ if ( $field['show_date'] == 'true') {
176
+ $value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
177
+ } else {
178
+ $value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
179
+ }
180
+ }
181
+ return $value;
182
+ }
183
+
184
+
185
+ function js_to_php_dateformat($date_format) {
186
+ $chars = array(
187
+ // Day
188
+ 'dd' => 'd', 'd' => 'j', 'DD' => 'l','D' => 'D', 'o' => 'z',
189
+ // Month
190
+ 'mm' => 'm', 'm' => 'n', 'MM' => 'F', 'M' => 'M',
191
+ // Year
192
+ 'yy' => 'Y', 'y' => 'y',
193
+ );
194
+
195
+ return strtr((string)$date_format, $chars);
196
+ }
197
+
198
+
199
+ function js_to_php_timeformat($time_format) {
200
+
201
+ $chars = array(
202
+ //hour
203
+ 'HH' => 'H', 'H' => 'G', 'hh' => 'h' , 'h' => 'g',
204
+ //minute
205
+ 'mm' => 'i', 'm' => 'i',
206
+ //second
207
+ 'ss' => 's', 's' => 's',
208
+ //am/pm
209
+ 'TT' => 'A', 'T' => 'A', 'tt' => 'a', 't' => 'a'
210
+ );
211
+
212
+ return strtr((string)$time_format, $chars);
213
+ }
214
+
215
+
216
+ function isValidTimeStamp($timestamp) {
217
+ return ((string)(int)$timestamp === (string)$timestamp);
218
+ }
219
+
220
+ /*
221
+ * load_value()
222
+ *
223
+ * This filter is applied to the $value after it is loaded from the db
224
+ *
225
+ * @type filter
226
+ * @since 3.6
227
+ * @date 23/01/13
228
+ *
229
+ * @param $value (mixed) the value found in the database
230
+ * @param $post_id (mixed) the $post_id from which the value was loaded
231
+ * @param $field (array) the field array holding all the field options
232
+ * @return $value
233
+ */
234
+ function load_value( $value, $post_id, $field ) {
235
+
236
+ $field = array_merge($this->defaults, $field);
237
+
238
+ if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) {
239
+ if ( $field['show_date'] == 'true') {
240
+ $value = date_i18n(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
241
+ } else {
242
+ $value = date_i18n(sprintf("%s",$this->js_to_php_timeformat($field['time_format'])), $value);
243
+ }
244
+ }
245
+ return $value;
246
+
247
+ }
248
+
249
+ /*
250
+ * update_value()
251
+ *
252
+ * This filter is appied to the $value before it is updated in the db
253
+ *
254
+ * @type filter
255
+ * @since 3.6
256
+ * @date 23/01/13
257
+ *
258
+ * @param $value - the value which will be saved in the database
259
+ * @param $post_id - the $post_id of which the value will be saved
260
+ * @param $field - the field array holding all the field options
261
+ *
262
+ * @return $value - the modified value
263
+ */
264
+
265
+ // function update_value( $value, $post_id, $field ) {
266
+ // $field = array_merge($this->defaults, $field);
267
+ // if ($value != '' && $field['save_as_timestamp'] == 'true') {
268
+ // $value = strtotime( $value );
269
+ // }
270
+ // return $value;
271
+ // }
272
+
273
+ function update_value( $value, $post_id, $field ) {
274
+ $field = array_merge($this->defaults, $field);
275
+ if ($value != '' && $field['save_as_timestamp'] == 'true') {
276
+ if (preg_match('/^dd?\//',$field['date_format'] )) { //if start with dd/ or d/ (not supported by strtotime())
277
+ $value = str_replace('/', '-', $value);
278
+ }
279
+ $value = strtotime( $value );
280
+ }
281
+
282
+ return $value;
283
+ }
284
+
285
+ /*
286
+ * input_admin_enqueue_scripts()
287
+ *
288
+ * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
289
+ * Use this action to add css + javascript to assist your create_field() action.
290
+ *
291
+ * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
292
+ * @type action
293
+ * @since 3.6
294
+ * @date 23/01/13
295
+ */
296
+
297
+ function input_admin_enqueue_scripts() {
298
+
299
+ global $wp_locale;
300
+
301
+
302
+ $has_locale = false;
303
+ $js_locale = $this->get_js_locale(get_locale());
304
+
305
+ wp_enqueue_script( 'jquery-ui-timepicker', $this->dir . 'js/jquery-ui-timepicker-addon.js', array(
306
+ 'acf-input',
307
+ 'jquery-ui-slider'
308
+ ), $this->version, true );
309
+
310
+ if ( file_exists( $this->path . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
311
+ wp_enqueue_script( 'timepicker-localization', $this->dir . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
312
+ 'jquery-ui-timepicker'
313
+ ), $this->version, true );
314
+ wp_enqueue_script( 'timepicker', $this->dir . 'js/timepicker.js', array(
315
+ 'timepicker-localization'
316
+ ), $this->version, true );
317
+ $has_locale = true;
318
+ } else {
319
+ wp_enqueue_script( 'timepicker', $this->dir . 'js/timepicker.js', array(
320
+ 'jquery-ui-timepicker'
321
+ ), $this->version, true );
322
+ }
323
+
324
+ if ( ! $has_locale && $js_locale != 'en' ) {
325
+ $timepicker_locale = array(
326
+ 'closeText' => __( 'Done', $this->domain )
327
+ , 'currentText' => __( 'Today', $this->domain )
328
+ , 'prevText' => __( 'Prev', $this->domain )
329
+ , 'nextText' => __( 'Next', $this->domain )
330
+ , 'monthStatus' => __( 'Show a different month', $this->domain )
331
+ , 'weekHeader' => __( 'Wk', $this->domain )
332
+ , 'timeText' => __( "Time", $this->domain )
333
+ , 'hourText' => __( "Hour", $this->domain )
334
+ , 'minuteText' => __( "Minute", $this->domain )
335
+ , 'secondText' => __( "Second", $this->domain )
336
+ , 'millisecText' => __( "Millisecond", $this->domain )
337
+ , 'timezoneText' => __( "Time Zone", $this->domain )
338
+ , 'isRTL' => $wp_locale->is_rtl()
339
+ );
340
+ }
341
+ $timepicker_wp_locale = array(
342
+ 'monthNames' => $this->strip_array_indices( $wp_locale->month )
343
+ , 'monthNamesShort' => $this->strip_array_indices( $wp_locale->month_abbrev )
344
+ , 'dayNames' => $this->strip_array_indices( $wp_locale->weekday )
345
+ , 'dayNamesShort' => $this->strip_array_indices( $wp_locale->weekday_abbrev )
346
+ , 'dayNamesMin' => $this->strip_array_indices( $wp_locale->weekday_initial )
347
+ , 'showMonthAfterYear' => false
348
+ , 'showWeek' => false
349
+ , 'firstDay' => get_option( 'start_of_week' )
350
+ );
351
+
352
+ $l10n = ( isset( $timepicker_locale ) ) ? array_merge( $timepicker_wp_locale, $timepicker_locale ) : $timepicker_wp_locale;
353
+ wp_localize_script( 'timepicker', 'timepicker_objectL10n', $l10n );
354
+
355
+ wp_enqueue_style('jquery-style', $this->dir . 'css/jquery-ui.css',array(
356
+ 'acf-datepicker'
357
+ ),$this->version);
358
+ wp_enqueue_style('timepicker', $this->dir . 'css/jquery-ui-timepicker-addon.css',array(
359
+ 'jquery-style'
360
+ ),$this->version);
361
+ }
362
+
363
+ /**
364
+ * helper function, see: http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n
365
+ * @param array $ArrayToStrip
366
+ * @return array
367
+ */
368
+ function strip_array_indices( $ArrayToStrip ) {
369
+ foreach ( $ArrayToStrip as $objArrayItem ) {
370
+ $NewArray[] = $objArrayItem;
371
+ }
372
+
373
+ return $NewArray;
374
+ }
375
+
376
+ function get_js_locale($locale) {
377
+ $dir_path = $this->path . 'js/localization/';
378
+ $exclude_list = array(".", "..");
379
+ $languages = $this->ps_preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
380
+
381
+ $locale = strtolower(str_replace("_", "-", $locale));
382
+
383
+ if (false !== strpos($locale,'-')) {
384
+ $l = explode("-",$locale);
385
+ $pattern = array('/' . $locale . '/','/' . $l[0] . '/', '/' . $l[1] . '/');
386
+ } else {
387
+ $pattern = array('/' . $locale . '/');
388
+ }
389
+ $res = $this->ps_preg_filter($pattern,"$0",$languages,-1,$count);
390
+
391
+ return ($count) ? implode("", $res) : 'en';
392
+ }
393
+
394
+
395
+ function ps_preg_filter ($pattern, $replace, $subject,$limit = -1, &$count = 0) {
396
+ if (function_exists('preg_filter'))
397
+ return preg_filter($pattern, $replace, $subject,$limit,$count);
398
+ else
399
+ return array_diff(preg_replace($pattern, $replace, $subject,$limit,$count), $subject);
400
+ }
401
+
402
+
403
+ }
404
+
405
+
406
+ // create field
407
+ new acf_field_date_time_picker();
408
+
409
+ ?>
js/input.js CHANGED
@@ -17,6 +17,8 @@
17
  */
18
 
19
  $(document).live('acf/setup_fields', function(e, postbox){
 
 
20
 
21
  $(postbox).find('.my-field-class').each(function(){
22
 
17
  */
18
 
19
  $(document).live('acf/setup_fields', function(e, postbox){
20
+
21
+ alert('test');
22
 
23
  $(postbox).find('.my-field-class').each(function(){
24
 
js/localization/jquery-ui-timepicker-da.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Danish translation for the jQuery Timepicker Addon */
2
+ /* Written by Lars H. Jensen (http://www.larshj.dk) */
3
+ (function ($) {
4
+ $.timepicker.regional['da'] = {
5
+ timeOnlyTitle: 'Vælg tid',
6
+ timeText: 'Tid',
7
+ hourText: 'Time',
8
+ minuteText: 'Minut',
9
+ secondText: 'Sekund',
10
+ millisecText: 'Millisekund',
11
+ microsecText: 'Mikrosekund',
12
+ timezoneText: 'Tidszone',
13
+ currentText: 'Nu',
14
+ closeText: 'Luk',
15
+ timeFormat: 'HH:mm',
16
+ amNames: ['am', 'AM', 'A'],
17
+ pmNames: ['pm', 'PM', 'P'],
18
+ isRTL: false
19
+ };
20
+ $.timepicker.setDefaults($.timepicker.regional['da']);
21
+ })(jQuery);
js/localization/jquery-ui-timepicker-hr.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Croatian translation for the jQuery Timepicker Addon */
2
+ /* Written by Mladen */
3
+ (function($) {
4
+ $.timepicker.regional['hr'] = {
5
+ timeOnlyTitle: 'Odaberi vrijeme',
6
+ timeText: 'Vrijeme',
7
+ hourText: 'Sati',
8
+ minuteText: 'Minute',
9
+ secondText: 'Sekunde',
10
+ millisecText: 'Milisekunde',
11
+ microsecText: 'Mikrosekunde',
12
+ timezoneText: 'Vremenska zona',
13
+ currentText: 'Sada',
14
+ closeText: 'Gotovo',
15
+ timeFormat: 'HH:mm',
16
+ amNames: ['a.m.', 'AM', 'A'],
17
+ pmNames: ['p.m.', 'PM', 'P'],
18
+ isRTL: false
19
+ };
20
+ $.timepicker.setDefaults($.timepicker.regional['hr']);
21
+ })(jQuery);
js/timepicker.js CHANGED
@@ -2,54 +2,152 @@
2
  * Date and Time Picker
3
  */
4
  (function($){
5
- $(document).live('acf/setup_fields', function(e, postbox){
6
- $(postbox).find('input.ps_timepicker').each(function(){
7
- var input = $(this)
8
- , is_timeonly = (input.attr('data-date_format') == undefined)
9
- , date_format = (input.attr('data-date_format') != undefined) ? input.attr('data-date_format') : 'mm/dd/yy'
10
- , time_format = input.attr('data-time_format')
11
- , has_ampm = (input.attr('data-time_format').search(/t/i) != -1);
12
-
13
- if( acf.helpers.is_clone_field(input) )
14
- {
15
- return;
16
- }
17
-
18
-
19
- input.addClass('active').attr("placeholder", (is_timeonly) ? time_format : date_format + ' ' + time_format).datetimepicker({
20
- changeYear: true
21
- , yearRange: "-100:+100"
22
- , changeMonth: true
23
- , timeOnly: is_timeonly
24
- , timeFormat: time_format
25
- , dateFormat: date_format
26
- , showWeek: (input.attr('data-show_week_number') != "true") ? 0 : 1
27
- , ampm: has_ampm
28
- , controlType: input.attr('data-picker')
29
- , timeOnlyTitle: input.attr('title')
30
- , monthNames: timepicker_objectL10n.monthNames
31
- , monthNamesShort: timepicker_objectL10n.monthNamesShort
32
- , dayNames: timepicker_objectL10n.dayNames
33
- , dayNamesShort: timepicker_objectL10n.dayNamesShort
34
- , dayNamesMin: timepicker_objectL10n.dayNamesMin
35
- , firstDay: timepicker_objectL10n.firstDay
36
- });
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- if($('body > #ui-datepicker-div').length > 0)
40
- {
41
- $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- // allow null
45
- input.blur(function(){
46
 
47
- if( !input.val() )
48
  {
49
- input.val('');
50
  }
 
 
 
 
 
 
 
 
 
51
  });
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  });
54
- });
55
  })(jQuery);
2
  * Date and Time Picker
3
  */
4
  (function($){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ function initialize_field( $el ) {
7
+
8
+ //$el.doStuff();
9
+
10
+ }
11
+
12
+
13
+ if( typeof acf.add_action !== 'undefined' ) {
14
+
15
+ /*
16
+ * ready append (ACF5)
17
+ *
18
+ * These are 2 events which are fired during the page load
19
+ * ready = on page load similar to $(document).ready()
20
+ * append = on new DOM elements appended via repeater field
21
+ *
22
+ * @type event
23
+ * @date 20/07/13
24
+ *
25
+ * @param $el (jQuery selection) the jQuery element which contains the ACF fields
26
+ * @return n/a
27
+ */
28
+
29
+ acf.add_action('ready append', function( $el ){
30
 
31
+ $el.find('input.ps_timepicker').each(function(){
32
+ var input = $(this)
33
+ , is_timeonly = (input.attr('data-date_format') == undefined)
34
+ , date_format = (input.attr('data-date_format') != undefined) ? input.attr('data-date_format') : 'mm/dd/yy'
35
+ , time_format = input.attr('data-time_format')
36
+ , has_ampm = (input.attr('data-time_format').search(/t/i) != -1);
37
+
38
+ /*if( acf.helpers.is_clone_field(input) )
39
+ {
40
+ return;
41
+ }*/
42
+
43
+
44
+ input.addClass('active').attr("placeholder", (is_timeonly) ? time_format : date_format + ' ' + time_format).datetimepicker({
45
+ changeYear: true
46
+ , yearRange: "-100:+100"
47
+ , changeMonth: true
48
+ , timeOnly: is_timeonly
49
+ , timeFormat: time_format
50
+ , dateFormat: date_format
51
+ , showWeek: (input.attr('data-show_week_number') != "true") ? 0 : 1
52
+ , ampm: has_ampm
53
+ , controlType: input.attr('data-picker')
54
+ , timeOnlyTitle: input.attr('title')
55
+ , monthNames: timepicker_objectL10n.monthNames
56
+ , monthNamesShort: timepicker_objectL10n.monthNamesShort
57
+ , dayNames: timepicker_objectL10n.dayNames
58
+ , dayNamesShort: timepicker_objectL10n.dayNamesShort
59
+ , dayNamesMin: timepicker_objectL10n.dayNamesMin
60
+ , firstDay: timepicker_objectL10n.firstDay
61
+ });
62
 
 
 
63
 
64
+ if($('body > #ui-datepicker-div').length > 0)
65
  {
66
+ $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
67
  }
68
+
69
+ // allow null
70
+ input.blur(function(){
71
+
72
+ if( !input.val() )
73
+ {
74
+ input.val('');
75
+ }
76
+ });
77
  });
78
 
79
+
80
+
81
+ });
82
+
83
+
84
+ } else {
85
+
86
+
87
+ /*
88
+ * acf/setup_fields (ACF4)
89
+ *
90
+ * This event is triggered when ACF adds any new elements to the DOM.
91
+ *
92
+ * @type function
93
+ * @since 1.0.0
94
+ * @date 01/01/12
95
+ *
96
+ * @param event e: an event object. This can be ignored
97
+ * @param Element postbox: An element which contains the new HTML
98
+ *
99
+ * @return n/a
100
+ */
101
+
102
+ $(document).live('acf/setup_fields', function(e, postbox){
103
+
104
+ $(postbox).find('input.ps_timepicker').each(function(){
105
+ var input = $(this)
106
+ , is_timeonly = (input.attr('data-date_format') == undefined)
107
+ , date_format = (input.attr('data-date_format') != undefined) ? input.attr('data-date_format') : 'mm/dd/yy'
108
+ , time_format = input.attr('data-time_format')
109
+ , has_ampm = (input.attr('data-time_format').search(/t/i) != -1);
110
+
111
+ if( acf.helpers.is_clone_field(input) )
112
+ {
113
+ return;
114
+ }
115
+
116
+
117
+ input.addClass('active').attr("placeholder", (is_timeonly) ? time_format : date_format + ' ' + time_format).datetimepicker({
118
+ changeYear: true
119
+ , yearRange: "-100:+100"
120
+ , changeMonth: true
121
+ , timeOnly: is_timeonly
122
+ , timeFormat: time_format
123
+ , dateFormat: date_format
124
+ , showWeek: (input.attr('data-show_week_number') != "true") ? 0 : 1
125
+ , ampm: has_ampm
126
+ , controlType: input.attr('data-picker')
127
+ , timeOnlyTitle: input.attr('title')
128
+ , monthNames: timepicker_objectL10n.monthNames
129
+ , monthNamesShort: timepicker_objectL10n.monthNamesShort
130
+ , dayNames: timepicker_objectL10n.dayNames
131
+ , dayNamesShort: timepicker_objectL10n.dayNamesShort
132
+ , dayNamesMin: timepicker_objectL10n.dayNamesMin
133
+ , firstDay: timepicker_objectL10n.firstDay
134
+ });
135
+
136
+
137
+ if($('body > #ui-datepicker-div').length > 0)
138
+ {
139
+ $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
140
+ }
141
+
142
+ // allow null
143
+ input.blur(function(){
144
+
145
+ if( !input.val() )
146
+ {
147
+ input.val('');
148
+ }
149
+ });
150
+ });
151
  });
152
+ }
153
  })(jQuery);
languages/acf-field-date-time-picker.po ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Advanced Custom Fields: Date and Time Picker\n"
4
+ "POT-Creation-Date: 2014-05-05 16:57+0100\n"
5
+ "PO-Revision-Date: 2014-05-05 16:58+0100\n"
6
+ "Last-Translator: Per Søderlind <per@soderlind.no>\n"
7
+ "Language-Team: Per Søderlind <per@soderlind.no>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.6.5\n"
12
+ "X-Poedit-Basepath: ..\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
15
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
16
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: date_time_picker-v3.php:28 date_time_picker-v3.php:138
20
+ #: date_time_picker-v4.php:24 date_time_picker-v4.php:84
21
+ msgid "Date and Time Picker"
22
+ msgstr ""
23
+
24
+ #: date_time_picker-v3.php:31 date_time_picker-v4.php:28
25
+ msgid "Choose Time"
26
+ msgstr ""
27
+
28
+ #: date_time_picker-v3.php:128 date_time_picker-v4.php:74
29
+ msgid "Date and Time Picker?"
30
+ msgstr ""
31
+
32
+ #: date_time_picker-v3.php:139 date_time_picker-v4.php:85
33
+ msgid "Time Picker"
34
+ msgstr ""
35
+
36
+ #: date_time_picker-v3.php:147 date_time_picker-v4.php:93
37
+ msgid "Date Format"
38
+ msgstr ""
39
+
40
+ #: date_time_picker-v3.php:148
41
+ msgid "eg. mm/dd/yy. read more about"
42
+ msgstr ""
43
+
44
+ #: date_time_picker-v3.php:162 date_time_picker-v4.php:124
45
+ msgid "Time Format"
46
+ msgstr ""
47
+
48
+ #: date_time_picker-v3.php:163 date_time_picker-v4.php:125
49
+ #, php-format
50
+ msgid ""
51
+ "eg. hh:mm. read more about <a href=\"%s\" target=\"_blank\">formatting "
52
+ "time</a>"
53
+ msgstr ""
54
+
55
+ #: date_time_picker-v3.php:177 date_time_picker-v4.php:152
56
+ msgid "Display Week Number?"
57
+ msgstr ""
58
+
59
+ #: date_time_picker-v3.php:187 date_time_picker-v3.php:226
60
+ #: date_time_picker-v3.php:246 date_time_picker-v4.php:162
61
+ #: date_time_picker-v4.php:201 date_time_picker-v4.php:221
62
+ msgid "Yes"
63
+ msgstr ""
64
+
65
+ #: date_time_picker-v3.php:188 date_time_picker-v3.php:227
66
+ #: date_time_picker-v3.php:247 date_time_picker-v4.php:163
67
+ #: date_time_picker-v4.php:202 date_time_picker-v4.php:222
68
+ msgid "No"
69
+ msgstr ""
70
+
71
+ #: date_time_picker-v3.php:196
72
+ msgid "Time Picker Style?"
73
+ msgstr ""
74
+
75
+ #: date_time_picker-v3.php:206 date_time_picker-v4.php:181
76
+ msgid "Slider"
77
+ msgstr ""
78
+
79
+ #: date_time_picker-v3.php:207 date_time_picker-v4.php:182
80
+ msgid "Dropdown"
81
+ msgstr ""
82
+
83
+ #: date_time_picker-v3.php:215 date_time_picker-v4.php:190
84
+ msgid "Save as timestamp?"
85
+ msgstr ""
86
+
87
+ #: date_time_picker-v3.php:216 date_time_picker-v4.php:191
88
+ #, php-format
89
+ msgid ""
90
+ "Most users should leave this untouched, only set it to \"No\" if you need a "
91
+ "date and time format not supported by <a href=\"%s\" target=\"_blank"
92
+ "\">strtotime</a>"
93
+ msgstr ""
94
+
95
+ #: date_time_picker-v3.php:235
96
+ msgid "Get field as a timestamp?"
97
+ msgstr ""
98
+
99
+ #: date_time_picker-v3.php:236 date_time_picker-v4.php:211
100
+ #, php-format
101
+ msgid ""
102
+ "Most users should leave this untouched, only set it to \"Yes\" if you need "
103
+ "get the date and time field as a timestamp using <a href=\"%s\" target="
104
+ "\"_blank\">the_field()</a> or <a href=\"%s\" target=\"_blank\">get_field()</"
105
+ "a> "
106
+ msgstr ""
107
+
108
+ #: date_time_picker-v3.php:426 date_time_picker-v4.php:394
109
+ msgid "Done"
110
+ msgstr ""
111
+
112
+ #: date_time_picker-v3.php:427 date_time_picker-v4.php:395
113
+ msgid "Today"
114
+ msgstr ""
115
+
116
+ #: date_time_picker-v3.php:428 date_time_picker-v4.php:396
117
+ msgid "Prev"
118
+ msgstr ""
119
+
120
+ #: date_time_picker-v3.php:429 date_time_picker-v4.php:397
121
+ msgid "Next"
122
+ msgstr ""
123
+
124
+ #: date_time_picker-v3.php:430 date_time_picker-v4.php:398
125
+ msgid "Show a different month"
126
+ msgstr ""
127
+
128
+ #: date_time_picker-v3.php:431 date_time_picker-v4.php:399
129
+ msgid "Wk"
130
+ msgstr ""
131
+
132
+ #: date_time_picker-v3.php:432 date_time_picker-v4.php:400
133
+ msgid "Time"
134
+ msgstr ""
135
+
136
+ #: date_time_picker-v3.php:433 date_time_picker-v4.php:401
137
+ msgid "Hour"
138
+ msgstr ""
139
+
140
+ #: date_time_picker-v3.php:434 date_time_picker-v4.php:402
141
+ msgid "Minute"
142
+ msgstr ""
143
+
144
+ #: date_time_picker-v3.php:435 date_time_picker-v4.php:403
145
+ msgid "Second"
146
+ msgstr ""
147
+
148
+ #: date_time_picker-v3.php:436 date_time_picker-v4.php:404
149
+ msgid "Millisecond"
150
+ msgstr ""
151
+
152
+ #: date_time_picker-v3.php:437 date_time_picker-v4.php:405
153
+ msgid "Time Zone"
154
+ msgstr ""
155
+
156
+ #: date_time_picker-v4.php:25
157
+ msgid "jQuery"
158
+ msgstr ""
159
+
160
+ #: date_time_picker-v4.php:94
161
+ #, php-format
162
+ msgid ""
163
+ "eg. mm/dd/yy. read more about <a href=\"%s\" target=\"_blank\">formatting "
164
+ "date</a>"
165
+ msgstr ""
166
+
167
+ #: date_time_picker-v4.php:171
168
+ msgid "Time Picker style?"
169
+ msgstr ""
170
+
171
+ #: date_time_picker-v4.php:210
172
+ msgid "Get field as timestamp?"
173
+ msgstr ""
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: 3.9
7
- Stable tag: 2.0.14
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -15,7 +15,7 @@ Date and Time Picker field for Advanced Custom Fields
15
 
16
  This is an add-on for the [Advanced Custom Fields](http://wordpress.org/extend/plugins/advanced-custom-fields/) WordPress plugin, that allows you to add a Date and Time Picker field type.
17
 
18
- NOTE: v 2.0.13 and onwards requiers at least ACF 4.3.5
19
 
20
  [youtube http://www.youtube.com/watch?v=Mumx4HGOljQ]
21
 
@@ -23,7 +23,7 @@ NOTE: v 2.0.13 and onwards requiers at least ACF 4.3.5
23
 
24
  This add-on will work with:
25
 
26
- * Advanced Custom Fields version 4 and up
27
  * Advanced Custom Fields version 3 and bellow
28
 
29
  = More Information =
@@ -112,6 +112,8 @@ TT AM or PM for AM/PM
112
  The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date](http://php.net/manual/en/function.date.php) function when you use it in your theme.
113
 
114
  == Changelog ==
 
 
115
  = 2.0.14 =
116
  * Added new languages/acf-field-date-time-picker.po file (note, renamed the language file)
117
  = 2.0.13 =
4
  Tags: acf, custom field,datepicker,timepicker
5
  Requires at least: 3.6
6
  Tested up to: 3.9
7
+ Stable tag: 2.0.15.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
15
 
16
  This is an add-on for the [Advanced Custom Fields](http://wordpress.org/extend/plugins/advanced-custom-fields/) WordPress plugin, that allows you to add a Date and Time Picker field type.
17
 
18
+ Thanks to [yanknudtskov](https://github.com/yanknudtskov), the plugin now works with ACF 5.0
19
 
20
  [youtube http://www.youtube.com/watch?v=Mumx4HGOljQ]
21
 
23
 
24
  This add-on will work with:
25
 
26
+ * Advanced Custom Fields version 4.3.5 and up (including ACF 5.0)
27
  * Advanced Custom Fields version 3 and bellow
28
 
29
  = More Information =
112
  The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date](http://php.net/manual/en/function.date.php) function when you use it in your theme.
113
 
114
  == Changelog ==
115
+ = 2.0.15 =
116
+ * Thanks to [yanknudtskov](https://github.com/yanknudtskov), the plugin now works with ACF 5.0
117
  = 2.0.14 =
118
  * Added new languages/acf-field-date-time-picker.po file (note, renamed the language file)
119
  = 2.0.13 =