Advanced Custom Fields - Version 3.3.8

Version Description

  • [Added] Gallery field { auto add image on upload, new style to show already added images
  • [Fixed] Fix saving value issue with WP e-commerce http://support.advancedcustomfields.com/discussion/comment/7026#Comment_7026
  • [Updated] Date picker field { new display format option (different from save format), UI overhaul
  • [Added] Add new field - Number
  • [Fixed] Test post object / select based fields for saving empty value - http://support.advancedcustomfields.com/discussion/2759/post-object-and-conditional-statement
Download this release

Release Info

Developer elliotcondon
Plugin Icon 128x128 Advanced Custom Fields
Version 3.3.8
Comparing to
See all releases

Code changes from version 3.3.7 to 3.3.8

acf.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
  Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
6
- Version: 3.3.7
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -47,7 +47,7 @@ class Acf
47
  // vars
48
  $this->path = plugin_dir_path(__FILE__);
49
  $this->dir = plugins_url('',__FILE__);
50
- $this->version = '3.3.7';
51
  $this->upgrade_version = '3.3.3'; // this is the latest version which requires an upgrade
52
  $this->cache = array(); // basic array cache to hold data throughout the page load
53
 
@@ -149,6 +149,7 @@ class Acf
149
  include_once('core/fields/wysiwyg.php');
150
  include_once('core/fields/image.php');
151
  include_once('core/fields/file.php');
 
152
  include_once('core/fields/select.php');
153
  include_once('core/fields/checkbox.php');
154
  include_once('core/fields/radio.php');
@@ -166,6 +167,7 @@ class Acf
166
  $return['wysiwyg'] = new acf_Wysiwyg($this);
167
  $return['image'] = new acf_Image($this);
168
  $return['file'] = new acf_File($this);
 
169
  $return['select'] = new acf_Select($this);
170
  $return['checkbox'] = new acf_Checkbox($this);
171
  $return['radio'] = new acf_Radio($this);
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
  Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
6
+ Version: 3.3.8
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
47
  // vars
48
  $this->path = plugin_dir_path(__FILE__);
49
  $this->dir = plugins_url('',__FILE__);
50
+ $this->version = '3.3.8';
51
  $this->upgrade_version = '3.3.3'; // this is the latest version which requires an upgrade
52
  $this->cache = array(); // basic array cache to hold data throughout the page load
53
 
149
  include_once('core/fields/wysiwyg.php');
150
  include_once('core/fields/image.php');
151
  include_once('core/fields/file.php');
152
+ include_once('core/fields/number.php');
153
  include_once('core/fields/select.php');
154
  include_once('core/fields/checkbox.php');
155
  include_once('core/fields/radio.php');
167
  $return['wysiwyg'] = new acf_Wysiwyg($this);
168
  $return['image'] = new acf_Image($this);
169
  $return['file'] = new acf_File($this);
170
+ $return['number'] = new acf_Number($this);
171
  $return['select'] = new acf_Select($this);
172
  $return['checkbox'] = new acf_Checkbox($this);
173
  $return['radio'] = new acf_Radio($this);
core/controllers/input.php CHANGED
@@ -35,7 +35,7 @@ class acf_input
35
  add_action('admin_print_scripts', array($this,'admin_print_scripts'));
36
  add_action('admin_print_styles', array($this,'admin_print_styles'));
37
  add_action('admin_head', array($this,'admin_head'));
38
- add_action('save_post', array($this, 'save_post'));
39
 
40
 
41
  // custom actions (added in 3.1.8)
@@ -592,7 +592,7 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
592
  }
593
 
594
  #wpcontent {
595
- margin-left: 0px;
596
  }
597
 
598
  .wrap {
35
  add_action('admin_print_scripts', array($this,'admin_print_scripts'));
36
  add_action('admin_print_styles', array($this,'admin_print_styles'));
37
  add_action('admin_head', array($this,'admin_head'));
38
+ add_action('save_post', array($this, 'save_post'), 20); // save later to avoid issues with 3rd party plugins
39
 
40
 
41
  // custom actions (added in 3.1.8)
592
  }
593
 
594
  #wpcontent {
595
+ margin-left: 0px !important;
596
  }
597
 
598
  .wrap {
core/fields/acf_field.php CHANGED
@@ -222,38 +222,6 @@ class acf_Field
222
  return $this->get_value($post_id, $field);
223
  }
224
 
225
-
226
- /*--------------------------------------------------------------------------------------
227
- *
228
- * format_value_for_input
229
- * -
230
- *
231
- * @author Elliot Condon
232
- * @since 2.2.0
233
- *
234
- *-------------------------------------------------------------------------------------
235
-
236
- function format_value_for_input($value, $field)
237
- {
238
- return $value;
239
- }
240
- */
241
-
242
- /*--------------------------------------------------------------------------------------
243
- *
244
- * format_value_for_api
245
- * -
246
- *
247
- * @author Elliot Condon
248
- * @since 2.2.0
249
- *
250
- *-------------------------------------------------------------------------------------
251
-
252
- function format_value_for_api($value, $field)
253
- {
254
- return $value;
255
- }
256
- */
257
  }
258
 
259
  ?>
222
  return $this->get_value($post_id, $field);
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  }
226
 
227
  ?>
core/fields/date_picker/date_picker.php CHANGED
@@ -52,11 +52,18 @@ class acf_Date_picker extends acf_Field
52
 
53
  function create_field($field)
54
  {
55
- // vars
56
- $field['date_format'] = isset($field['date_format']) ? $field['date_format'] : 'dd/mm/yy';
 
 
 
57
 
 
 
 
58
  // html
59
- echo '<input type="text" value="' . $field['value'] . '" class="acf_datepicker" name="' . $field['name'] . '" data-date_format="' . $field['date_format'] . '" />';
 
60
 
61
  }
62
 
@@ -74,19 +81,35 @@ class acf_Date_picker extends acf_Field
74
  function create_options($key, $field)
75
  {
76
  // defaults
77
- $field['date_format'] = isset($field['date_format']) ? $field['date_format'] : '';
 
 
 
78
 
 
 
 
79
  ?>
80
  <tr class="field_option field_option_<?php echo $this->name; ?>">
81
  <td class="label">
82
- <label><?php _e("Date format",'acf'); ?></label>
83
- <p class="description"><?php _e("eg. dd/mm/yy. read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
 
84
  </td>
85
  <td>
86
  <input type="text" name="fields[<?php echo $key; ?>][date_format]" value="<?php echo $field['date_format']; ?>" />
87
  </td>
88
  </tr>
89
-
 
 
 
 
 
 
 
 
 
90
  <?php
91
  }
92
 
52
 
53
  function create_field($field)
54
  {
55
+ // defaults
56
+ $defaults = array(
57
+ 'date_format' => 'yymmdd',
58
+ 'display_format' => 'dd/mm/yy',
59
+ );
60
 
61
+ $field = array_merge($defaults, $field);
62
+
63
+
64
  // html
65
+ echo '<input type="hidden" value="' . $field['value'] . '" name="' . $field['name'] . '" class="acf-hidden-datepicker" />';
66
+ echo '<input type="text" value="" class="acf_datepicker" data-save_format="' . $field['date_format'] . '" data-display_format="' . $field['display_format'] . '" />';
67
 
68
  }
69
 
81
  function create_options($key, $field)
82
  {
83
  // defaults
84
+ $defaults = array(
85
+ 'date_format' => 'yymmdd',
86
+ 'display_format' => 'dd/mm/yy',
87
+ );
88
 
89
+ $field = array_merge($defaults, $field);
90
+
91
+
92
  ?>
93
  <tr class="field_option field_option_<?php echo $this->name; ?>">
94
  <td class="label">
95
+ <label><?php _e("Save format",'acf'); ?></label>
96
+ <p class="description"><?php _e("This format will determin the value saved to the database and returned via the API",'acf'); ?></p>
97
+ <p><?php _e("\"yymmdd\" is the most versatile save format. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
98
  </td>
99
  <td>
100
  <input type="text" name="fields[<?php echo $key; ?>][date_format]" value="<?php echo $field['date_format']; ?>" />
101
  </td>
102
  </tr>
103
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
104
+ <td class="label">
105
+ <label><?php _e("Display format",'acf'); ?></label>
106
+ <p class="description"><?php _e("This format will be seen by the user when entering a value",'acf'); ?></p>
107
+ <p><?php _e("\"dd/mm/yy\" or \"mm/dd/yy\" are the most used display formats. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
108
+ </td>
109
+ <td>
110
+ <input type="text" name="fields[<?php echo $key; ?>][display_format]" value="<?php echo $field['display_format']; ?>" />
111
+ </td>
112
+ </tr>
113
  <?php
114
  }
115
 
core/fields/date_picker/style.date_picker.css CHANGED
@@ -59,14 +59,34 @@
59
  .ui-acf .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
60
  .ui-acf .ui-widget .ui-widget { font-size: 1em; }
61
  .ui-acf .ui-widget input, .ui-acf .ui-widget select, .ui-acf .ui-widget textarea, .ui-acf .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
62
- .ui-acf .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
 
 
 
 
 
63
  .ui-acf .ui-widget-content a { color: #222222; }
64
- .ui-acf .ui-widget-header { border: 1px solid #000000; background: #444444 url(images/ui-bg_highlight-soft_0_444444_1x100.png) 50% 50% repeat-x; color: #e5e5e5; font-weight: bold; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  .ui-acf .ui-widget-header a { color: #e5e5e5; }
66
 
67
  /* Interaction states
68
  ----------------------------------*/
69
- .ui-acf .ui-state-default, .ui-acf .ui-widget-content .ui-state-default, .ui-acf .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
70
  .ui-acf .ui-state-default a, .ui-acf .ui-state-default a:link, .ui-acf .ui-state-default a:visited { color: #555555; text-decoration: none; }
71
  .ui-acf .ui-state-hover, .ui-acf .ui-widget-content .ui-state-hover, .ui-acf .ui-widget-header .ui-state-hover, .ui-acf .ui-state-focus, .ui-acf .ui-widget-content .ui-state-focus, .ui-acf .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
72
  .ui-acf .ui-state-hover a, .ui-acf .ui-state-hover a:hover { color: #212121; text-decoration: none; }
@@ -296,22 +316,22 @@
296
  *
297
  * http://docs.jquery.com/UI/Datepicker#theming
298
  */
299
- .ui-acf .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
300
- .ui-acf .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
301
- .ui-acf .ui-datepicker .ui-datepicker-prev, .ui-acf .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
302
  .ui-acf .ui-datepicker .ui-datepicker-prev-hover, .ui-acf .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
303
  .ui-acf .ui-datepicker .ui-datepicker-prev { left:2px; }
304
  .ui-acf .ui-datepicker .ui-datepicker-next { right:2px; }
305
  .ui-acf .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
306
  .ui-acf .ui-datepicker .ui-datepicker-next-hover { right:1px; }
307
  .ui-acf .ui-datepicker .ui-datepicker-prev span, .ui-acf .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
308
- .ui-acf .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
309
- .ui-acf .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
310
  .ui-acf .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
311
  .ui-acf .ui-datepicker select.ui-datepicker-month,
312
- .ui-acf .ui-datepicker select.ui-datepicker-year { width: 49%;}
313
  .ui-acf .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
314
- .ui-acf .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
315
  .ui-acf .ui-datepicker td { border: 0; padding: 1px; }
316
  .ui-acf .ui-datepicker td span, .ui-acf .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
317
  .ui-acf .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
@@ -354,4 +374,48 @@
354
  left: -4px; /*must have*/
355
  width: 200px; /*must have*/
356
  height: 200px; /*must have*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  }
59
  .ui-acf .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
60
  .ui-acf .ui-widget .ui-widget { font-size: 1em; }
61
  .ui-acf .ui-widget input, .ui-acf .ui-widget select, .ui-acf .ui-widget textarea, .ui-acf .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
62
+ .ui-acf .ui-widget-content {
63
+ border: 1px solid #E1E1E1;
64
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
65
+ color: #222222;
66
+ background: #fff;
67
+ }
68
  .ui-acf .ui-widget-content a { color: #222222; }
69
+ .ui-acf .ui-widget-header {
70
+ background: #2c8bbe;
71
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* Safari 4+, Chrome */
72
+ background-image: -webkit-linear-gradient(top, #2c8bbe, #246f99); /* Chrome 10+, Safari 5.1+, iOS 5+ */
73
+ background-image: -moz-linear-gradient(top, #2c8bbe, #246f99); /* Firefox 3.6-15 */
74
+ background-image: -o-linear-gradient(top, #2c8bbe, #246f99); /* Opera 11.10+ */
75
+ background-image: linear-gradient(to bottom, #2c8bbe, #246f99); /* Firefox 16+ */
76
+ color: #e5e5e5;
77
+ font-weight: bold;
78
+ border-radius: 0 !important;
79
+ width: 100%;
80
+ padding: 8px 3px;
81
+ position: relative;
82
+ margin: -3px 0 0 -3px;
83
+ }
84
+
85
  .ui-acf .ui-widget-header a { color: #e5e5e5; }
86
 
87
  /* Interaction states
88
  ----------------------------------*/
89
+ .ui-acf .ui-state-default, .ui-acf .ui-widget-content .ui-state-default, .ui-acf .ui-widget-header .ui-state-default { border: 1px solid #E1E1E1; background: #F9F9F9; font-weight: normal; color: #555555; }
90
  .ui-acf .ui-state-default a, .ui-acf .ui-state-default a:link, .ui-acf .ui-state-default a:visited { color: #555555; text-decoration: none; }
91
  .ui-acf .ui-state-hover, .ui-acf .ui-widget-content .ui-state-hover, .ui-acf .ui-widget-header .ui-state-hover, .ui-acf .ui-state-focus, .ui-acf .ui-widget-content .ui-state-focus, .ui-acf .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
92
  .ui-acf .ui-state-hover a, .ui-acf .ui-state-hover a:hover { color: #212121; text-decoration: none; }
316
  *
317
  * http://docs.jquery.com/UI/Datepicker#theming
318
  */
319
+ .ui-acf .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; border-radius: 0 !important; }
320
+ .ui-acf .ui-datepicker .ui-datepicker-header { }
321
+ .ui-acf .ui-datepicker .ui-datepicker-prev, .ui-acf .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; display: none; }
322
  .ui-acf .ui-datepicker .ui-datepicker-prev-hover, .ui-acf .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
323
  .ui-acf .ui-datepicker .ui-datepicker-prev { left:2px; }
324
  .ui-acf .ui-datepicker .ui-datepicker-next { right:2px; }
325
  .ui-acf .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
326
  .ui-acf .ui-datepicker .ui-datepicker-next-hover { right:1px; }
327
  .ui-acf .ui-datepicker .ui-datepicker-prev span, .ui-acf .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
328
+ .ui-acf .ui-datepicker .ui-datepicker-title { margin: 0; }
329
+ .ui-acf .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:0 0 0 2%; }
330
  .ui-acf .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
331
  .ui-acf .ui-datepicker select.ui-datepicker-month,
332
+ .ui-acf .ui-datepicker select.ui-datepicker-year { width: 47%; padding: 1px; font-size: 12px; font-weight: normal;}
333
  .ui-acf .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
334
+ .ui-acf .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; width: 14%; }
335
  .ui-acf .ui-datepicker td { border: 0; padding: 1px; }
336
  .ui-acf .ui-datepicker td span, .ui-acf .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
337
  .ui-acf .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
374
  left: -4px; /*must have*/
375
  width: 200px; /*must have*/
376
  height: 200px; /*must have*/
377
+ }
378
+
379
+ .ui-acf .ui-datepicker .ui-datepicker-buttonpane {
380
+ background: #EAF2FA;
381
+ border-top: 1px solid #E1E1E1;
382
+ width: 100%;
383
+ padding: 3px;
384
+ margin: 0;
385
+ margin: 0 0 0 -3px;
386
+ position: relative;
387
+ overflow: hidden;
388
+ }
389
+
390
+ .ui-acf .ui-datepicker .ui-datepicker-buttonpane button {
391
+ margin: 0;
392
+ padding: 0px;
393
+ font-size: 12px;
394
+ background: transparent;
395
+ border: 0 none;
396
+ text-shadow: 0 1px 0 #FFFFFF;
397
+ color: #7A9BBE;
398
+ opacity: 1;
399
+ display: block;line-height: 1em;
400
+ padding: 5px;
401
+ }
402
+
403
+ .ui-acf .ui-datepicker .ui-state-highlight {
404
+ background: #EAF2FA;
405
+ color: #555555;
406
+ border: 1px solid #95B1CE;
407
+ }
408
+
409
+ .ui-acf .ui-datepicker .ui-state-active {
410
+ background: #2c8bbe;
411
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* Safari 4+, Chrome */
412
+ background-image: -webkit-linear-gradient(top, #2c8bbe, #246f99); /* Chrome 10+, Safari 5.1+, iOS 5+ */
413
+ background-image: -moz-linear-gradient(top, #2c8bbe, #246f99); /* Firefox 3.6-15 */
414
+ background-image: -o-linear-gradient(top, #2c8bbe, #246f99); /* Opera 11.10+ */
415
+ background-image: linear-gradient(to bottom, #2c8bbe, #246f99); /* Firefox 16+ */
416
+
417
+ color: #FFFFFF;
418
+ text-shadow: 0 1px 0 rgba(0,0,0,0.5);
419
+ border: #246f99 solid 1px;
420
+
421
  }
core/fields/gallery.php CHANGED
@@ -288,24 +288,6 @@ class acf_Gallery extends acf_Field
288
  </div>
289
  <?php
290
  }
291
-
292
-
293
- /*--------------------------------------------------------------------------------------
294
- *
295
- * admin_head
296
- * - this function is called in the admin_head of the edit screen where your field
297
- * is created. Use this function to create css and javascript to assist your
298
- * create_field() function.
299
- *
300
- * @author Elliot Condon
301
- * @since 2.2.0
302
- *
303
- *-------------------------------------------------------------------------------------*/
304
-
305
- function admin_head()
306
- {
307
-
308
- }
309
 
310
 
311
  /*--------------------------------------------------------------------------------------
@@ -555,18 +537,62 @@ class acf_Gallery extends acf_Field
555
  .acf-message-wrapper .message {
556
  margin: 2px 2px 0;
557
  }
 
 
 
 
 
 
 
 
558
 
559
  </style>
560
  <script type="text/javascript">
561
  (function($){
562
 
563
 
564
- // global vars
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  var gallery,
566
  tmpl_thumbnail;
567
 
568
 
569
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
570
  /*
571
  * Select Image
572
  *
@@ -588,7 +614,8 @@ class acf_Gallery extends acf_Field
588
 
589
 
590
  // show added message
591
- self.parent.acf.add_message('<?php _e("Image Added",'acf'); ?>.', div);
 
592
 
593
 
594
  // add image
@@ -646,13 +673,34 @@ class acf_Gallery extends acf_Field
646
 
647
 
648
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
649
  }
650
  <?php
651
 
652
  // run the acf_add_buttons ever 500ms when on the image upload tab
653
  if($options['tab'] == 'type'): ?>
654
  var acf_t = setInterval(function(){
 
655
  acf_add_buttons();
 
 
 
 
 
 
 
656
  }, 500);
657
  <?php endif; ?>
658
 
@@ -660,8 +708,16 @@ class acf_Gallery extends acf_Field
660
  // add acf input filters to allow for tab navigation
661
  $(document).ready(function(){
662
 
 
 
 
 
 
 
663
  setTimeout(function(){
 
664
  acf_add_buttons();
 
665
  }, 1);
666
 
667
 
@@ -679,6 +735,8 @@ class acf_Gallery extends acf_Field
679
  $(this).attr('action', action);
680
 
681
  });
 
 
682
  });
683
 
684
 
@@ -772,24 +830,7 @@ class acf_Gallery extends acf_Field
772
  });
773
  // $.ajax({
774
  }
775
-
776
-
777
- /*
778
- * Document Ready
779
- *
780
- * @description:
781
- * @created: 2/07/12
782
- */
783
-
784
- $(document).ready(function(){
785
-
786
-
787
- // vars
788
- gallery = self.parent.acf_div;
789
- tmpl_thumbnail = gallery.find('.tmpl-thumbnail').html();
790
-
791
-
792
- });
793
 
794
  })(jQuery);
795
  </script><?php
288
  </div>
289
  <?php
290
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
 
293
  /*--------------------------------------------------------------------------------------
537
  .acf-message-wrapper .message {
538
  margin: 2px 2px 0;
539
  }
540
+
541
+ #media-items .media-item.media-item-added {
542
+ background: #F9F9F9;
543
+ }
544
+
545
+ #wpcontent {
546
+ margin-left: 0 !important;
547
+ }
548
 
549
  </style>
550
  <script type="text/javascript">
551
  (function($){
552
 
553
 
554
+ /*
555
+ * Exists
556
+ *
557
+ * @description: returns true / false
558
+ * @created: 1/03/2011
559
+ */
560
+
561
+ $.fn.exists = function()
562
+ {
563
+ return $(this).length>0;
564
+ };
565
+
566
+
567
+ /*
568
+ * global vars
569
+ *
570
+ * @description:
571
+ * @created: 16/08/12
572
+ */
573
  var gallery,
574
  tmpl_thumbnail;
575
 
576
 
577
+ /*
578
+ * Disable / Enable image
579
+ *
580
+ * @description:
581
+ * @created: 16/08/12
582
+ */
583
+
584
+ function disable_image( div )
585
+ {
586
+ // add class
587
+ div.addClass('media-item-added');
588
+
589
+
590
+ // change button text
591
+ div.find('.acf-select').addClass('disabled').text("<?php _e("Added",'acf'); ?>");
592
+
593
+ }
594
+
595
+
596
  /*
597
  * Select Image
598
  *
614
 
615
 
616
  // show added message
617
+ //self.parent.acf.add_message('<?php _e("Image Added",'acf'); ?>.', div);
618
+ disable_image( div );
619
 
620
 
621
  // add image
673
 
674
 
675
  });
676
+
677
+
678
+ // disable images
679
+ gallery.find('.thumbnails .thumbnail input[type="hidden"]').each(function(){
680
+
681
+ var div = $('#media-item-' + $(this).val());
682
+
683
+ if( div.exists() )
684
+ {
685
+ disable_image( div );
686
+ }
687
+
688
+ });
689
  }
690
  <?php
691
 
692
  // run the acf_add_buttons ever 500ms when on the image upload tab
693
  if($options['tab'] == 'type'): ?>
694
  var acf_t = setInterval(function(){
695
+
696
  acf_add_buttons();
697
+
698
+ // auto add images
699
+ $('#media-items .media-item:not(.media-item-added)').each(function(){
700
+ $(this).find('a.acf-select').trigger('click');
701
+ });
702
+
703
+
704
  }, 500);
705
  <?php endif; ?>
706
 
708
  // add acf input filters to allow for tab navigation
709
  $(document).ready(function(){
710
 
711
+ // vars
712
+ gallery = self.parent.acf_div;
713
+ tmpl_thumbnail = gallery.find('.tmpl-thumbnail').html();
714
+
715
+
716
+ // add buttins
717
  setTimeout(function(){
718
+
719
  acf_add_buttons();
720
+
721
  }, 1);
722
 
723
 
735
  $(this).attr('action', action);
736
 
737
  });
738
+
739
+
740
  });
741
 
742
 
830
  });
831
  // $.ajax({
832
  }
833
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
834
 
835
  })(jQuery);
836
  </script><?php
core/fields/number.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class acf_Number extends acf_Field
4
+ {
5
+
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
+ {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'number';
21
+ $this->title = __("Number",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
+
36
+ function create_field($field)
37
+ {
38
+ echo '<input type="number" step="any" value="' . $field['value'] . '" id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" />';
39
+ }
40
+
41
+
42
+ /*--------------------------------------------------------------------------------------
43
+ *
44
+ * update_value
45
+ *
46
+ * @author Elliot Condon
47
+ * @since 2.2.0
48
+ *
49
+ *-------------------------------------------------------------------------------------*/
50
+
51
+ function update_value($post_id, $field, $value)
52
+ {
53
+ // remove ','
54
+ $value = str_replace(',', '', $value);
55
+
56
+
57
+ // convert to float. This removes any chars
58
+ $value = floatval( $value );
59
+
60
+
61
+ // convert back to string. This alows decimals to save
62
+ $value = (string) $value;
63
+
64
+
65
+ // update value
66
+ parent::update_value($post_id, $field, $value);
67
+
68
+ }
69
+
70
+ }
71
+
72
+ ?>
core/fields/select.php CHANGED
@@ -36,13 +36,17 @@ class acf_Select extends acf_Field
36
 
37
  function create_field($field)
38
  {
39
- // defaults
40
- $field['value'] = isset($field['value']) ? $field['value'] : array();
41
- $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : false;
42
- $field['allow_null'] = isset($field['allow_null']) ? $field['allow_null'] : false;
43
- $field['choices'] = isset($field['choices']) ? $field['choices'] : array();
44
- $field['optgroup'] = isset($field['optgroup']) ? $field['optgroup'] : false;
 
 
45
 
 
 
46
 
47
  // no choices
48
  if(empty($field['choices']))
@@ -51,17 +55,23 @@ class acf_Select extends acf_Field
51
  return false;
52
  }
53
 
 
54
  // multiple select
55
  $multiple = '';
56
  if($field['multiple'] == '1')
57
  {
 
 
 
58
  $multiple = ' multiple="multiple" size="5" ';
59
  $field['name'] .= '[]';
60
  }
61
 
 
62
  // html
63
  echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
64
 
 
65
  // null
66
  if($field['allow_null'] == '1')
67
  {
36
 
37
  function create_field($field)
38
  {
39
+ // vars
40
+ $defaults = array(
41
+ 'value' => array(),
42
+ 'multiple' => '0',
43
+ 'allow_null' => '0',
44
+ 'choices' => array(),
45
+ 'optgroup' => false,
46
+ );
47
 
48
+ $field = array_merge($defaults, $field);
49
+
50
 
51
  // no choices
52
  if(empty($field['choices']))
55
  return false;
56
  }
57
 
58
+
59
  // multiple select
60
  $multiple = '';
61
  if($field['multiple'] == '1')
62
  {
63
+ // create a hidden field to allow for no selections
64
+ echo '<input type="hidden" name="' . $field['name'] . '" />';
65
+
66
  $multiple = ' multiple="multiple" size="5" ';
67
  $field['name'] .= '[]';
68
  }
69
 
70
+
71
  // html
72
  echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
73
 
74
+
75
  // null
76
  if($field['allow_null'] == '1')
77
  {
core/views/meta_box_options.php CHANGED
@@ -21,7 +21,7 @@ $options = $this->parent->get_acf_options($post->ID);
21
  <tr>
22
  <td class="label">
23
  <label for=""><?php _e("Order No.",'acf'); ?></label>
24
- <p class="description"><?php _e("Field groups are created in order <br />from lowest to highest.",'acf'); ?></p>
25
  </td>
26
  <td>
27
  <?php
21
  <tr>
22
  <td class="label">
23
  <label for=""><?php _e("Order No.",'acf'); ?></label>
24
+ <p class="description"><?php _e("Field groups are created in order <br />from lowest to highest",'acf'); ?></p>
25
  </td>
26
  <td>
27
  <?php
css/acf.css CHANGED
Binary file
css/global.css CHANGED
@@ -273,10 +273,14 @@ a.acf-button,
273
  input[type="submit"].acf-button {
274
  display: block;
275
  border-radius: 4px;
 
276
  background: #2c8bbe;
277
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2c8bbe', endColorstr='#246f99'); /* for IE */
278
- background: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* for webkit browsers */
279
- background: -moz-linear-gradient(top, #2c8bbe, #246f99); /* for firefox 3.6+ */
 
 
 
280
  color: #FFFFFF;
281
  font-weight: normal;
282
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
@@ -294,10 +298,13 @@ input[type="submit"].acf-button {
294
  a.acf-button:hover,
295
  input[type="submit"].acf-button:hover {
296
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
 
297
  background: #3b97c9;
298
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3b97c9', endColorstr='#246f99'); /* for IE */
299
- background: -webkit-gradient(linear, left top, left bottom, from(#3b97c9), to(#246f99)); /* for webkit browsers */
300
- background: -moz-linear-gradient(top, #3b97c9, #246f99); /* for firefox 3.6+ */
 
 
301
  }
302
 
303
  a.acf-button:active,
@@ -311,10 +318,13 @@ a.acf-button.grey,
311
  input[type="submit"].acf-button.grey {
312
  text-shadow: 0 1px 0 #fff;
313
  color: #454545;
 
314
  background: #fff;
315
- filter: progid:DXImageTransform.Microsoft.Gradient(startColorstr='#ffffff', endColorstr='#ececec'); /* for IE */
316
- background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ececec)); /* for webkit browsers */
317
- background: -moz-linear-gradient(top, #fff, #ececec); /* for firefox 3.6+ */
 
 
318
 
319
  }
320
 
@@ -328,8 +338,11 @@ a.acf-button[disabled]:hover,
328
  .disabled a.acf-button:hover,
329
  input[type="submit"].acf-button[disabled]:hover {
330
  background: #2c8bbe;
331
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2c8bbe', endColorstr='#246f99'); /* for IE */
332
- background: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* for webkit browsers */
333
- background: -moz-linear-gradient(top, #2c8bbe, #246f99); /* for firefox 3.6+ */
 
 
 
334
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
335
  }
273
  input[type="submit"].acf-button {
274
  display: block;
275
  border-radius: 4px;
276
+
277
  background: #2c8bbe;
278
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* Safari 4+, Chrome */
279
+ background-image: -webkit-linear-gradient(top, #2c8bbe, #246f99); /* Chrome 10+, Safari 5.1+, iOS 5+ */
280
+ background-image: -moz-linear-gradient(top, #2c8bbe, #246f99); /* Firefox 3.6-15 */
281
+ background-image: -o-linear-gradient(top, #2c8bbe, #246f99); /* Opera 11.10+ */
282
+ background-image: linear-gradient(to bottom, #2c8bbe, #246f99); /* Firefox 16+ */
283
+
284
  color: #FFFFFF;
285
  font-weight: normal;
286
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
298
  a.acf-button:hover,
299
  input[type="submit"].acf-button:hover {
300
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
301
+
302
  background: #3b97c9;
303
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#3b97c9), to(#246f99)); /* Safari 4+, Chrome */
304
+ background-image: -webkit-linear-gradient(top, #3b97c9, #246f99); /* Chrome 10+, Safari 5.1+, iOS 5+ */
305
+ background-image: -moz-linear-gradient(top, #3b97c9, #246f99); /* Firefox 3.6-15 */
306
+ background-image: -o-linear-gradient(top, #3b97c9, #246f99); /* Opera 11.10+ */
307
+ background-image: linear-gradient(to bottom, #3b97c9, #246f99); /* Firefox 16+ */
308
  }
309
 
310
  a.acf-button:active,
318
  input[type="submit"].acf-button.grey {
319
  text-shadow: 0 1px 0 #fff;
320
  color: #454545;
321
+
322
  background: #fff;
323
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ececec)); /* Safari 4+, Chrome */
324
+ background-image: -webkit-linear-gradient(top, #ffffff, #ececec); /* Chrome 10+, Safari 5.1+, iOS 5+ */
325
+ background-image: -moz-linear-gradient(top, #ffffff, #ececec); /* Firefox 3.6-15 */
326
+ background-image: -o-linear-gradient(top, #ffffff, #ececec); /* Opera 11.10+ */
327
+ background-image: linear-gradient(to bottom, #ffffff, #ececec); /* Firefox 16+ */
328
 
329
  }
330
 
338
  .disabled a.acf-button:hover,
339
  input[type="submit"].acf-button[disabled]:hover {
340
  background: #2c8bbe;
341
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* Safari 4+, Chrome */
342
+ background-image: -webkit-linear-gradient(top, #2c8bbe, #246f99); /* Chrome 10+, Safari 5.1+, iOS 5+ */
343
+ background-image: -moz-linear-gradient(top, #2c8bbe, #246f99); /* Firefox 3.6-15 */
344
+ background-image: -o-linear-gradient(top, #2c8bbe, #246f99); /* Opera 11.10+ */
345
+ background-image: linear-gradient(to bottom, #2c8bbe, #246f99); /* Firefox 16+ */
346
+
347
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
348
  }
css/input.css CHANGED
@@ -105,6 +105,7 @@
105
  ---------------------------------------------------------------------------------------------*/
106
 
107
  .acf_postbox .field input[type="text"],
 
108
  .acf_postbox .field input[type="password"],
109
  .acf_postbox .field textarea{
110
  width: 100%;
105
  ---------------------------------------------------------------------------------------------*/
106
 
107
  .acf_postbox .field input[type="text"],
108
+ .acf_postbox .field input[type="number"],
109
  .acf_postbox .field input[type="password"],
110
  .acf_postbox .field textarea{
111
  width: 100%;
js/input-actions.js CHANGED
@@ -131,7 +131,7 @@ var acf = {
131
  var validation = true;
132
 
133
  // text / textarea
134
- if($(this).find('input[type="text"], input[type="hidden"], textarea').val() == "")
135
  {
136
  validation = false;
137
  }
@@ -1222,25 +1222,35 @@ var acf = {
1222
  * @created: 4/03/2011
1223
  */
1224
 
1225
- $('input.acf_datepicker').live('focus', function(){
1226
-
1227
- var input = $(this);
1228
 
1229
- if(!input.hasClass('active'))
1230
- {
1231
 
1232
  // vars
1233
- var format = input.attr('data-date_format') ? input.attr('data-date_format') : 'dd/mm/yy';
 
 
 
 
 
 
 
 
1234
 
1235
  // add date picker and refocus
1236
  input.addClass('active').datepicker({
1237
- dateFormat: format
1238
- })
 
 
 
 
 
 
 
 
 
1239
 
1240
- // set a timeout to re focus the input (after it has the datepicker!)
1241
- setTimeout(function(){
1242
- input.trigger('blur').trigger('focus');
1243
- }, 1);
1244
 
1245
  // wrap the datepicker (only if it hasn't already been wrapped)
1246
  if($('body > #ui-datepicker-div').length > 0)
@@ -1248,7 +1258,7 @@ var acf = {
1248
  $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
1249
  }
1250
 
1251
- }
1252
 
1253
  });
1254
 
131
  var validation = true;
132
 
133
  // text / textarea
134
+ if($(this).find('input[type="text"], input[type="number"], input[type="hidden"], textarea').val() == "")
135
  {
136
  validation = false;
137
  }
1222
  * @created: 4/03/2011
1223
  */
1224
 
1225
+ $(document).live('acf/setup_fields', function(e, postbox){
 
 
1226
 
1227
+ $(postbox).find('input.acf_datepicker').each(function(){
 
1228
 
1229
  // vars
1230
+ var input = $(this),
1231
+ alt_field = input.siblings('.acf-hidden-datepicker');
1232
+ save_format = input.attr('data-save_format'),
1233
+ display_format = input.attr('data-display_format');
1234
+
1235
+
1236
+ // get and set value from alt field
1237
+ input.val( alt_field.val() );
1238
+
1239
 
1240
  // add date picker and refocus
1241
  input.addClass('active').datepicker({
1242
+ dateFormat : save_format,
1243
+ altField : alt_field,
1244
+ altFormat : save_format,
1245
+ changeYear: true,
1246
+ changeMonth: true,
1247
+ showButtonPanel : true
1248
+ });
1249
+
1250
+
1251
+ // now change the format back to how it should be.
1252
+ input.datepicker( "option", "dateFormat", display_format );
1253
 
 
 
 
 
1254
 
1255
  // wrap the datepicker (only if it hasn't already been wrapped)
1256
  if($('body > #ui-datepicker-div').length > 0)
1258
  $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
1259
  }
1260
 
1261
+ });
1262
 
1263
  });
1264
 
readme.txt CHANGED
@@ -85,6 +85,13 @@ http://support.advancedcustomfields.com/
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
88
  = 3.3.7 =
89
  * [Added] Add new return value for image { image object
90
  * [Updated] Update Dutch translation (thanks to Derk Oosterveld - www.inpoint.nl)
85
 
86
  == Changelog ==
87
 
88
+ = 3.3.8 =
89
+ * [Added] Gallery field { auto add image on upload, new style to show already added images
90
+ * [Fixed] Fix saving value issue with WP e-commerce http://support.advancedcustomfields.com/discussion/comment/7026#Comment_7026
91
+ * [Updated] Date picker field { new display format option (different from save format), UI overhaul
92
+ * [Added] Add new field - Number
93
+ * [Fixed] Test post object / select based fields for saving empty value - http://support.advancedcustomfields.com/discussion/2759/post-object-and-conditional-statement
94
+
95
  = 3.3.7 =
96
  * [Added] Add new return value for image { image object
97
  * [Updated] Update Dutch translation (thanks to Derk Oosterveld - www.inpoint.nl)