Version Description
- Bug fix. 2.0.6 assumed that the stored date and time was in UNIX timestamp format. 2.0.7 will check and only convert if the date and time is.
Download this release
Release Info
Developer | PerS |
Plugin | Date and Time Picker Field |
Version | 2.0.7 |
Comparing to | |
See all releases |
Code changes from version 2.0.6 to 2.0.7
- acf-date_time_picker.php +1 -1
- date_time_picker-v3.php +8 -2
- date_time_picker-v4.php +8 -3
- readme.txt +3 -4
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.7
|
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 |
|
@@ -278,7 +278,7 @@ class acf_field_date_time_picker extends acf_Field {
|
|
278 |
function get_value($post_id, $field){
|
279 |
$value = parent::get_value($post_id, $field);
|
280 |
|
281 |
-
if ($value != '') {
|
282 |
if ( $field['show_date'] == 'true') {
|
283 |
$value = date(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
284 |
} else {
|
@@ -319,6 +319,12 @@ class acf_field_date_time_picker extends acf_Field {
|
|
319 |
return strtr((string)$time_format, $chars);
|
320 |
}
|
321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
/*--------------------------------------------------------------------------------------
|
323 |
*
|
324 |
* admin_print_scripts / admin_print_styles
|
40 |
$this->settings = array(
|
41 |
'path' => $this->helpers_get_path( __FILE__ )
|
42 |
, 'dir' => $this->helpers_get_dir( __FILE__ )
|
43 |
+
, 'version' => '2.0.7'
|
44 |
);
|
45 |
}
|
46 |
|
278 |
function get_value($post_id, $field){
|
279 |
$value = parent::get_value($post_id, $field);
|
280 |
|
281 |
+
if ($value != '' && $this->isValidTimeStamp($value)) {
|
282 |
if ( $field['show_date'] == 'true') {
|
283 |
$value = date(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
284 |
} else {
|
319 |
return strtr((string)$time_format, $chars);
|
320 |
}
|
321 |
|
322 |
+
function isValidTimeStamp($timestamp) { //from http://stackoverflow.com/a/2524761/1434155
|
323 |
+
return ((string) (int) $timestamp === $timestamp)
|
324 |
+
&& ($timestamp <= PHP_INT_MAX)
|
325 |
+
&& ($timestamp >= ~PHP_INT_MAX);
|
326 |
+
}
|
327 |
+
|
328 |
/*--------------------------------------------------------------------------------------
|
329 |
*
|
330 |
* admin_print_scripts / admin_print_styles
|
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 |
}
|
@@ -201,7 +201,7 @@ class acf_field_date_time_picker extends acf_field
|
|
201 |
*/
|
202 |
|
203 |
function load_value( $value, $post_id, $field ) {
|
204 |
-
if ($value != '') {
|
205 |
if ( $field['show_date'] == 'true') {
|
206 |
$value = date(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
207 |
} else {
|
@@ -242,7 +242,12 @@ class acf_field_date_time_picker extends acf_field
|
|
242 |
return strtr((string)$time_format, $chars);
|
243 |
}
|
244 |
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
246 |
/*
|
247 |
* update_value()
|
248 |
*
|
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.7'
|
49 |
);
|
50 |
|
51 |
}
|
201 |
*/
|
202 |
|
203 |
function load_value( $value, $post_id, $field ) {
|
204 |
+
if ($value != '' && $this->isValidTimeStamp($value)) {
|
205 |
if ( $field['show_date'] == 'true') {
|
206 |
$value = date(sprintf("%s %s",$this->js_to_php_dateformat($field['date_format']),$this->js_to_php_timeformat($field['time_format'])), $value);
|
207 |
} else {
|
242 |
return strtr((string)$time_format, $chars);
|
243 |
}
|
244 |
|
245 |
+
|
246 |
+
function isValidTimeStamp($timestamp) { //from http://stackoverflow.com/a/2524761/1434155
|
247 |
+
return ((string) (int) $timestamp === $timestamp)
|
248 |
+
&& ($timestamp <= PHP_INT_MAX)
|
249 |
+
&& ($timestamp >= ~PHP_INT_MAX);
|
250 |
+
}
|
251 |
/*
|
252 |
* update_value()
|
253 |
*
|
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 |
|
@@ -12,7 +12,6 @@ Date and Time Picker field for Advanced Custom Fields
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
= NOTE! 2.0.6 HAS A BUG, ON SITES USING PREVIOUS VERSION THE UPGRADE WILL RESET THE DATE AND TIME. 2.0.7 WILL SOON BE AVAILABLE =
|
16 |
|
17 |
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.
|
18 |
|
@@ -112,8 +111,8 @@ The Date and Time Picker field is saved as an UNIX timestamp. Use the PHP [date]
|
|
112 |
|
113 |
== Changelog ==
|
114 |
|
115 |
-
=
|
116 |
-
|
117 |
= 2.0.6 =
|
118 |
* Changed how the Date and Time Picker field is triggered when ACF adds a new Date and Time Picker field to the DOM
|
119 |
* Saves the Date and Time Picker field as an UNIX timestamp to MySQL. Use the PHP [date](http://php.net/manual/en/function.date.php) function when you use it in your 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.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
|
|
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 |
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 2.0.7 =
|
115 |
+
* Bug fix. 2.0.6 assumed that the stored date and time was in UNIX timestamp format. 2.0.7 will check and only convert if the date and time is.
|
116 |
= 2.0.6 =
|
117 |
* Changed how the Date and Time Picker field is triggered when ACF adds a new Date and Time Picker field to the DOM
|
118 |
* Saves the Date and Time Picker field as an UNIX timestamp to MySQL. Use the PHP [date](http://php.net/manual/en/function.date.php) function when you use it in your theme.
|