Version Description
- Updated JavaScript language detection and loading
Download this release
Release Info
Developer | PerS |
Plugin | Date and Time Picker Field |
Version | 2.0.4 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.4
- acf-date_time_picker.php +1 -1
- date_time_picker-v3.php +22 -5
- date_time_picker-v4.php +22 -7
- js/timepicker.js +0 -3
- readme.txt +52 -2
acf-date_time_picker.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Custom Fields: date_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.
|
7 |
Author: Per Soderlind
|
8 |
Author URI: http://soderlind.no
|
9 |
License: GPLv2 or later
|
3 |
Plugin Name: Advanced Custom Fields: date_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.4
|
7 |
Author: Per Soderlind
|
8 |
Author URI: http://soderlind.no
|
9 |
License: GPLv2 or later
|
date_time_picker-v3.php
CHANGED
@@ -40,7 +40,7 @@ class acf_field_date_time_picker extends acf_Field {
|
|
40 |
$this->settings = array(
|
41 |
'path' => $this->helpers_get_path( __FILE__ )
|
42 |
, 'dir' => $this->helpers_get_dir( __FILE__ )
|
43 |
-
, 'version' => '2.0.
|
44 |
);
|
45 |
}
|
46 |
|
@@ -320,12 +320,29 @@ class acf_field_date_time_picker extends acf_Field {
|
|
320 |
}
|
321 |
|
322 |
function get_js_locale($locale) {
|
323 |
-
$
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
} else {
|
327 |
-
|
328 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
|
331 |
|
40 |
$this->settings = array(
|
41 |
'path' => $this->helpers_get_path( __FILE__ )
|
42 |
, 'dir' => $this->helpers_get_dir( __FILE__ )
|
43 |
+
, 'version' => '2.0.4'
|
44 |
);
|
45 |
}
|
46 |
|
320 |
}
|
321 |
|
322 |
function get_js_locale($locale) {
|
323 |
+
$dir_path = $this->settings['path'] . 'js/localization/';
|
324 |
+
$exclude_list = array(".", "..");
|
325 |
+
$languages = $this->ps_preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
|
326 |
+
|
327 |
+
$locale = strtolower(str_replace("_", "-", $locale));
|
328 |
+
|
329 |
+
if (false !== strpos($locale,'-')) {
|
330 |
+
$l = explode("-",$locale);
|
331 |
+
$pattern = array('/' . $locale . '/','/' . $l[0] . '/', '/' . $l[1] . '/');
|
332 |
} else {
|
333 |
+
$pattern = array('/' . $locale . '/');
|
334 |
}
|
335 |
+
$res = $this->ps_preg_filter($pattern,"$0",$languages,-1,$count);
|
336 |
+
|
337 |
+
return ($count) ? implode("", $res) : 'en';
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
function ps_preg_filter ($pattern, $replace, $subject,$limit = -1, &$count = 0) {
|
342 |
+
if (function_exists('preg_filter'))
|
343 |
+
return preg_filter($pattern, $replace, $subject,$limit,$count);
|
344 |
+
else
|
345 |
+
return array_diff(preg_replace($pattern, $replace, $subject,$limit,$count), $subject);
|
346 |
}
|
347 |
|
348 |
|
date_time_picker-v4.php
CHANGED
@@ -45,7 +45,7 @@ class acf_field_date_time_picker extends acf_field
|
|
45 |
$this->settings = array(
|
46 |
'path' => apply_filters('acf/helpers/get_path', __FILE__)
|
47 |
, 'dir' => apply_filters('acf/helpers/get_dir', __FILE__)
|
48 |
-
, 'version' => '2.0.
|
49 |
);
|
50 |
|
51 |
}
|
@@ -233,12 +233,13 @@ class acf_field_date_time_picker extends acf_field
|
|
233 |
|
234 |
$has_locale = false;
|
235 |
$js_locale = $this->get_js_locale(get_locale());
|
|
|
236 |
wp_enqueue_script( 'jquery-ui-timepicker', $this->settings['dir'] . 'js/jquery-ui-timepicker-addon.js', array(
|
237 |
'jquery-ui-datepicker',
|
238 |
'jquery-ui-slider'
|
239 |
), $this->settings['version'], true );
|
240 |
|
241 |
-
if ( file_exists(
|
242 |
wp_enqueue_script( 'timepicker-localization', $this->settings['dir'] . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
243 |
'jquery-ui-timepicker'
|
244 |
), $this->settings['version'], true );
|
@@ -303,18 +304,32 @@ class acf_field_date_time_picker extends acf_field
|
|
303 |
}
|
304 |
|
305 |
function get_js_locale($locale) {
|
306 |
-
$
|
307 |
-
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
} else {
|
310 |
-
|
311 |
}
|
|
|
|
|
|
|
312 |
}
|
313 |
|
314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
|
317 |
-
|
318 |
}
|
319 |
|
320 |
|
45 |
$this->settings = array(
|
46 |
'path' => apply_filters('acf/helpers/get_path', __FILE__)
|
47 |
, 'dir' => apply_filters('acf/helpers/get_dir', __FILE__)
|
48 |
+
, 'version' => '2.0.4'
|
49 |
);
|
50 |
|
51 |
}
|
233 |
|
234 |
$has_locale = false;
|
235 |
$js_locale = $this->get_js_locale(get_locale());
|
236 |
+
|
237 |
wp_enqueue_script( 'jquery-ui-timepicker', $this->settings['dir'] . 'js/jquery-ui-timepicker-addon.js', array(
|
238 |
'jquery-ui-datepicker',
|
239 |
'jquery-ui-slider'
|
240 |
), $this->settings['version'], true );
|
241 |
|
242 |
+
if ( file_exists( $this->settings['path'] . '/js/localization/jquery-ui-timepicker-' . $js_locale . '.js' ) ) {
|
243 |
wp_enqueue_script( 'timepicker-localization', $this->settings['dir'] . 'js/localization/jquery-ui-timepicker-' . $js_locale . '.js', array(
|
244 |
'jquery-ui-timepicker'
|
245 |
), $this->settings['version'], true );
|
304 |
}
|
305 |
|
306 |
function get_js_locale($locale) {
|
307 |
+
$dir_path = $this->settings['path'] . 'js/localization/';
|
308 |
+
$exclude_list = array(".", "..");
|
309 |
+
$languages = $this->ps_preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
|
310 |
+
|
311 |
+
$locale = strtolower(str_replace("_", "-", $locale));
|
312 |
+
|
313 |
+
if (false !== strpos($locale,'-')) {
|
314 |
+
$l = explode("-",$locale);
|
315 |
+
$pattern = array('/' . $locale . '/','/' . $l[0] . '/', '/' . $l[1] . '/');
|
316 |
} else {
|
317 |
+
$pattern = array('/' . $locale . '/');
|
318 |
}
|
319 |
+
$res = $this->ps_preg_filter($pattern,"$0",$languages,-1,$count);
|
320 |
+
|
321 |
+
return ($count) ? implode("", $res) : 'en';
|
322 |
}
|
323 |
|
324 |
|
325 |
+
function ps_preg_filter ($pattern, $replace, $subject,$limit = -1, &$count = 0) {
|
326 |
+
if (function_exists('preg_filter'))
|
327 |
+
return preg_filter($pattern, $replace, $subject,$limit,$count);
|
328 |
+
else
|
329 |
+
return array_diff(preg_replace($pattern, $replace, $subject,$limit,$count), $subject);
|
330 |
+
}
|
331 |
|
332 |
|
|
|
333 |
}
|
334 |
|
335 |
|
js/timepicker.js
CHANGED
@@ -3,9 +3,6 @@ Attach a jQuery.datetimepicker() to "input[type=text].time_picker" fields. Will
|
|
3 |
*/
|
4 |
jQuery(function() {
|
5 |
jQuery(".field").on("focusin", "input[type=text].time_picker", function(){
|
6 |
-
//jQuery(document).live('acf/setup_fields', function(e, postbox){
|
7 |
-
// jQuery(postbox).find('.time_picker').each(function(){
|
8 |
-
|
9 |
self = jQuery(this);
|
10 |
self.datetimepicker({
|
11 |
timeOnly: (self.attr('data-date_format') == undefined),
|
3 |
*/
|
4 |
jQuery(function() {
|
5 |
jQuery(".field").on("focusin", "input[type=text].time_picker", function(){
|
|
|
|
|
|
|
6 |
self = jQuery(this);
|
7 |
self.datetimepicker({
|
8 |
timeOnly: (self.attr('data-date_format') == undefined),
|
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.4
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -52,8 +52,58 @@ function my_register_fields()
|
|
52 |
2. Date and Time Picker
|
53 |
3. Time Picker
|
54 |
|
55 |
-
== Changelog ==
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
= 2.0.3 =
|
58 |
* Fixed Repeater field bug
|
59 |
* Added support for including the field in a theme
|
4 |
Tags: acf, custom field,datepicker,timepicker
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 2.0.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
52 |
2. Date and Time Picker
|
53 |
3. Time Picker
|
54 |
|
|
|
55 |
|
56 |
+
== Frequently Asked Questions ==
|
57 |
+
|
58 |
+
|
59 |
+
**How do I set the date and time format?**
|
60 |
+
|
61 |
+
To set the date and time format when you create the field, you have to create a string using the letters below.
|
62 |
+
|
63 |
+
= Date format =
|
64 |
+
|
65 |
+
`
|
66 |
+
d day of month (no leading zero)
|
67 |
+
dd day of month (two digit)
|
68 |
+
o day of the year (no leading zeros)
|
69 |
+
oo day of the year (three digit)
|
70 |
+
D day name short
|
71 |
+
DD day name long
|
72 |
+
m month of year (no leading zero)
|
73 |
+
mm month of year (two digit)
|
74 |
+
M month name short
|
75 |
+
MM month name long
|
76 |
+
y year (two digit)
|
77 |
+
yy year (four digit)
|
78 |
+
`
|
79 |
+
|
80 |
+
= Time format =
|
81 |
+
|
82 |
+
`
|
83 |
+
H Hour with no leading 0 (24 hour)
|
84 |
+
HH Hour with leading 0 (24 hour)
|
85 |
+
h Hour with no leading 0 (12 hour)
|
86 |
+
hh Hour with leading 0 (12 hour)
|
87 |
+
m Minute with no leading 0
|
88 |
+
mm Minute with leading 0
|
89 |
+
s Second with no leading 0
|
90 |
+
ss Second with leading 0
|
91 |
+
l Milliseconds always with leading 0
|
92 |
+
t a or p for AM/PM
|
93 |
+
T A or P for AM/PM
|
94 |
+
tt am or pm for AM/PM
|
95 |
+
TT AM or PM for AM/PM
|
96 |
+
`
|
97 |
+
|
98 |
+
= Examples =
|
99 |
+
|
100 |
+
* `yy-mm-dd`: 2013-04-12
|
101 |
+
* `HH:mm`: 24 hour clock, with a leading 0 for hour and minute
|
102 |
+
* `h:m tt`: 12 hour clock with am/pm, no leading 0
|
103 |
+
|
104 |
+
== Changelog ==
|
105 |
+
= 2.0.4 =
|
106 |
+
* Updated JavaScript [language detection and loading](http://soderlind.no/time-picker-field-for-advanced-custom-fields/#localization)
|
107 |
= 2.0.3 =
|
108 |
* Fixed Repeater field bug
|
109 |
* Added support for including the field in a theme
|