Date and Time Picker Field - Version 2.0.3

Version Description

  • Fixed Repeater field bug
  • Added support for including the field in a theme
Download this release

Release Info

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

Code changes from version 2.0.2 to 2.0.3

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.2
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.3
7
  Author: Per Soderlind
8
  Author URI: http://soderlind.no
9
  License: GPLv2 or later
date_time_picker-v3.php CHANGED
@@ -38,13 +38,70 @@ class acf_field_date_time_picker extends acf_Field {
38
  );
39
 
40
  $this->settings = array(
41
- 'path' => plugin_dir_path( __FILE__)
42
- , 'dir' => plugin_dir_url( __FILE__)
43
- , 'version' => '2.0.0.beta'
44
- );
45
  }
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /*--------------------------------------------------------------------------------------
49
  *
50
  * create_options
38
  );
39
 
40
  $this->settings = array(
41
+ 'path' => $this->helpers_get_path( __FILE__ )
42
+ , 'dir' => $this->helpers_get_dir( __FILE__ )
43
+ , 'version' => '2.0.3'
44
+ );
45
  }
46
 
47
 
48
+ /*
49
+ * helpers_get_path
50
+ *
51
+ * @description: calculates the path (works for plugin / theme folders)
52
+ * @since: 3.6
53
+ * @created: 30/01/13
54
+ */
55
+
56
+ function helpers_get_path( $file ) {
57
+ return trailingslashit(dirname($file));
58
+ }
59
+
60
+
61
+
62
+ /*
63
+ * helpers_get_dir
64
+ *
65
+ * @description: calculates the directory (works for plugin / theme folders)
66
+ * @since: 3.6
67
+ * @created: 30/01/13
68
+ */
69
+
70
+ function helpers_get_dir( $file ) {
71
+ $dir = trailingslashit(dirname($file));
72
+ $count = 0;
73
+
74
+
75
+ // sanitize for Win32 installs
76
+ $dir = str_replace('\\' ,'/', $dir);
77
+
78
+
79
+ // if file is in plugins folder
80
+ $wp_plugin_dir = str_replace('\\' ,'/', WP_PLUGIN_DIR);
81
+ $dir = str_replace($wp_plugin_dir, WP_PLUGIN_URL, $dir, $count);
82
+
83
+
84
+ if( $count < 1 )
85
+ {
86
+ // if file is in wp-content folder
87
+ $wp_content_dir = str_replace('\\' ,'/', WP_CONTENT_DIR);
88
+ $dir = str_replace($wp_content_dir, WP_CONTENT_URL, $dir, $count);
89
+ }
90
+
91
+
92
+ if( $count < 1 )
93
+ {
94
+ // if file is in ??? folder
95
+ $wp_dir = str_replace('\\' ,'/', ABSPATH);
96
+ $dir = str_replace($wp_dir, site_url('/'), $dir);
97
+ }
98
+
99
+
100
+ return $dir;
101
+ }
102
+
103
+
104
+
105
  /*--------------------------------------------------------------------------------------
106
  *
107
  * create_options
date_time_picker-v4.php CHANGED
@@ -5,7 +5,8 @@ class acf_field_date_time_picker extends acf_field
5
  // vars
6
  var $settings // will hold info such as dir / path
7
  , $defaults // will hold default field options
8
- , $domain; // holds the language domain
 
9
 
10
  /*
11
  * __construct
@@ -31,6 +32,7 @@ class acf_field_date_time_picker extends acf_field
31
  , 'date_format' => 'mm/dd/yy'
32
  , 'show_week_number' => false
33
  , 'picker' => 'slider'
 
34
  );
35
 
36
 
@@ -43,7 +45,7 @@ class acf_field_date_time_picker extends acf_field
43
  $this->settings = array(
44
  'path' => apply_filters('acf/helpers/get_path', __FILE__)
45
  , 'dir' => apply_filters('acf/helpers/get_dir', __FILE__)
46
- , 'version' => '2.0.0.beta'
47
  );
48
 
49
  }
@@ -153,12 +155,40 @@ class acf_field_date_time_picker extends acf_field
153
  ) );
154
  ?>
155
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  </tr>
 
157
  <?php
158
 
159
  }
160
-
161
-
 
162
  /*
163
  * create_field()
164
  *
@@ -183,6 +213,8 @@ class acf_field_date_time_picker extends acf_field
183
  }
184
 
185
 
 
 
186
  /*
187
  * input_admin_enqueue_scripts()
188
  *
@@ -196,6 +228,7 @@ class acf_field_date_time_picker extends acf_field
196
  */
197
 
198
  function input_admin_enqueue_scripts() {
 
199
  global $wp_locale;
200
 
201
  $has_locale = false;
@@ -277,6 +310,10 @@ class acf_field_date_time_picker extends acf_field
277
  return $tmp_locale;
278
  }
279
  }
 
 
 
 
280
 
281
  }
282
 
5
  // vars
6
  var $settings // will hold info such as dir / path
7
  , $defaults // will hold default field options
8
+ , $domain // holds the language domain
9
+ , $lang;
10
 
11
  /*
12
  * __construct
32
  , 'date_format' => 'mm/dd/yy'
33
  , 'show_week_number' => false
34
  , 'picker' => 'slider'
35
+ , 'language' => 'en'
36
  );
37
 
38
 
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.3'
49
  );
50
 
51
  }
155
  ) );
156
  ?>
157
  </td>
158
+ </tr>
159
+ <?php /* ?>
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 language?", $this->domain ); ?></label>
163
+ </td>
164
+ <td>
165
+ <?php
166
+ $dir_path = $this->settings['path'] . 'js/localization/';
167
+ $exclude_list = array(".", "..");
168
+ $languages = preg_filter("/jquery-ui-timepicker-(.*?)\.js/","$1",array_diff(scandir($dir_path), $exclude_list));
169
+ $locales["en"] = "en";
170
+ foreach ($languages as $k => $v) {
171
+ $locales[$v] = $v;
172
+ }
173
+ asort($locales);
174
+ $locales["unknown"] = 'Use: "lang/' . $this->domain . '-' . get_locale() . '.mo"';
175
+
176
+ do_action('acf/create_field', array(
177
+ 'type' => 'select'
178
+ , 'name' => 'fields['.$key.'][language]'
179
+ , 'value' => $field['language']
180
+ , 'choices' => $locales
181
+ ) );
182
+ ?>
183
+ </td>
184
  </tr>
185
+ <?php */?>
186
  <?php
187
 
188
  }
189
+
190
+
191
+
192
  /*
193
  * create_field()
194
  *
213
  }
214
 
215
 
216
+
217
+
218
  /*
219
  * input_admin_enqueue_scripts()
220
  *
228
  */
229
 
230
  function input_admin_enqueue_scripts() {
231
+
232
  global $wp_locale;
233
 
234
  $has_locale = false;
310
  return $tmp_locale;
311
  }
312
  }
313
+
314
+
315
+
316
+
317
 
318
  }
319
 
js/timepicker.js CHANGED
@@ -1,10 +1,10 @@
1
  /*
2
  Attach a jQuery.datetimepicker() to "input[type=text].time_picker" fields. Will also attach to dynamic added fields.
3
  */
4
- //jQuery(function() {
5
- // jQuery("body").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({
1
  /*
2
  Attach a jQuery.datetimepicker() to "input[type=text].time_picker" fields. Will also attach to dynamic added fields.
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({
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.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -18,8 +18,8 @@ This is an add-on for the [Advanced Custom Fields](http://wordpress.org/extend/p
18
 
19
  This add-on will work with:
20
 
21
- * Advanced Custom Fields version 4 and up
22
- * Advanced Custom Fields version 3 and bellow
23
 
24
  = More Information =
25
 
@@ -27,9 +27,25 @@ This add-on will work with:
27
 
28
  == Installation ==
29
 
 
 
30
  1. Copy the 'acf-date_time_picker' folder into your plugins folder
31
  2. Activate the plugin via the Plugins admin page
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  == Screenshots ==
34
 
35
  1. Add the Date and Time Picker field
@@ -38,6 +54,9 @@ This add-on will work with:
38
 
39
  == Changelog ==
40
 
 
 
 
41
  = 2.0.2 =
42
  * Updated readme.txt
43
  = 2.0.1 =
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.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
18
 
19
  This add-on will work with:
20
 
21
+ * version 4 and up
22
+ * version 3 and bellow
23
 
24
  = More Information =
25
 
27
 
28
  == Installation ==
29
 
30
+
31
+ = Plugin =
32
  1. Copy the 'acf-date_time_picker' folder into your plugins folder
33
  2. Activate the plugin via the Plugins admin page
34
 
35
+ = Include =
36
+ 1. Copy the 'acf-date_time_picker' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
37
+ 2. Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-date_time_picker.php file)
38
+
39
+ `
40
+ add_action('acf/register_fields', 'my_register_fields');
41
+
42
+ function my_register_fields()
43
+ {
44
+ include_once('acf-date_time_picker/acf-date_time_picker.php');
45
+ }
46
+ `
47
+
48
+
49
  == Screenshots ==
50
 
51
  1. Add the Date and Time Picker field
54
 
55
  == Changelog ==
56
 
57
+ = 2.0.3 =
58
+ * Fixed Repeater field bug
59
+ * Added support for including the field in a theme
60
  = 2.0.2 =
61
  * Updated readme.txt
62
  = 2.0.1 =