Advanced Custom Fields - Version 3.2.8

Version Description

  • [Added] Repeater - Add option for min rows + max rows - http://www.advancedcustomfields.com/support/discussion/2111/repeater-empty-conditional-statements#Item_4
  • [Fixed] Test / Fix Chrome Double WYSIWYG. Again...
  • [Added] Add "future" to post status options - http://advancedcustomfields.com/support/discussion/1975/changed-line-81-and-94-of-corefieldspost_object-to-show-future-entries
  • [Added] Make image sizes strings "Pretty" for preview size options
  • [Fixed] Test / Fix WYSIWYG insert image inside a repeater bug - http://www.advancedcustomfields.com/support/discussion/2404/problem-with-repeater-wysiwyg-fields-and-images
Download this release

Release Info

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

Code changes from version 3.2.7 to 3.2.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 and more!
6
- Version: 3.2.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.2.7';
51
  $this->upgrade_version = '3.2.5'; // this is the latest version which requires an upgrade
52
  $this->cache = array(); // basic array cache to hold data throughout the page load
53
 
@@ -189,7 +189,15 @@ class Acf
189
  if($this->is_field_unlocked('flexible_content'))
190
  {
191
  include_once('core/fields/flexible_content.php');
192
- $return['flexible_content'] = new acf_flexible_content($this);
 
 
 
 
 
 
 
 
193
  }
194
 
195
 
@@ -1464,8 +1472,8 @@ class Acf
1464
  case 'flexible_content':
1465
  if(md5($this->get_license_key($field_name)) == "d067e06c2b4b32b1c1f5b6f00e0d61d6"){ return true; }else{ return false; }
1466
  break;
1467
- case 'everything_fields':
1468
- if(md5($this->get_license_key($field_name)) == "b6ecc9cd639f8f17d061b3eccad49b75"){ return true; }else{ return false; }
1469
  break;
1470
  }
1471
  }
@@ -1600,14 +1608,43 @@ class Acf
1600
 
1601
  }
1602
 
 
 
 
 
 
 
 
 
1603
 
1604
-
1605
-
1606
-
1607
-
1608
-
1609
-
1610
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1611
 
1612
 
1613
 
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 and more!
6
+ Version: 3.2.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.2.8';
51
  $this->upgrade_version = '3.2.5'; // this is the latest version which requires an upgrade
52
  $this->cache = array(); // basic array cache to hold data throughout the page load
53
 
189
  if($this->is_field_unlocked('flexible_content'))
190
  {
191
  include_once('core/fields/flexible_content.php');
192
+ $return['flexible_content'] = new acf_Flexible_content($this);
193
+ }
194
+
195
+
196
+ // add gallery
197
+ if($this->is_field_unlocked('gallery'))
198
+ {
199
+ include_once('core/fields/gallery.php');
200
+ $return['gallery'] = new acf_Gallery($this);
201
  }
202
 
203
 
1472
  case 'flexible_content':
1473
  if(md5($this->get_license_key($field_name)) == "d067e06c2b4b32b1c1f5b6f00e0d61d6"){ return true; }else{ return false; }
1474
  break;
1475
+ case 'gallery':
1476
+ if(md5($this->get_license_key($field_name)) == "69f4adc9883195bd206a868ffa954b49"){ return true; }else{ return false; }
1477
  break;
1478
  }
1479
  }
1608
 
1609
  }
1610
 
1611
+
1612
+ /*
1613
+ * get_all_image_sizes
1614
+ *
1615
+ * @description: returns an array holding all the image sizes
1616
+ * @since 3.2.8
1617
+ * @created: 6/07/12
1618
+ */
1619
 
1620
+ function get_all_image_sizes()
1621
+ {
1622
+ // find all sizes
1623
+ $all_sizes = get_intermediate_image_sizes();
1624
+
1625
+
1626
+ // define default sizes
1627
+ $image_sizes = array(
1628
+ 'thumbnail' => __("Thumbnail",'acf'),
1629
+ 'medium' => __("Medium",'acf'),
1630
+ 'large' => __("Large",'acf'),
1631
+ 'full' => __("Full",'acf')
1632
+ );
1633
+
1634
+
1635
+ // add extra registered sizes
1636
+ foreach($all_sizes as $size)
1637
+ {
1638
+ if (!isset($image_sizes[$size]))
1639
+ {
1640
+ $image_sizes[$size] = ucwords( str_replace('-', ' ', $size) );
1641
+ }
1642
+ }
1643
+
1644
+
1645
+ // return array
1646
+ return $image_sizes;
1647
+ }
1648
 
1649
 
1650
 
core/api.php CHANGED
@@ -505,12 +505,7 @@ function acf_form_wp_head()
505
 
506
  // Javascript
507
  echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
508
- echo '<script type="text/javascript">
509
- acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
510
- acf.post_id = ' . $post->ID . ';
511
- acf.editor_mode = "wysiwyg";
512
- acf.admin_url = "' . admin_url() . '";
513
- </script>';
514
 
515
 
516
  // add user js + css
505
 
506
  // Javascript
507
  echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
508
+ echo '<script type="text/javascript">acf.post_id = ' . $post->ID . ';</script>';
 
 
 
 
 
509
 
510
 
511
  // add user js + css
core/controllers/everything_fields.php CHANGED
@@ -194,11 +194,7 @@ class acf_everything_fields
194
 
195
  // Javascript
196
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
197
- echo '<script type="text/javascript">
198
- acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
199
- acf.post_id = 0;
200
- acf.admin_url = "' . admin_url() . '";
201
- </script>';
202
 
203
 
204
  // add user js + css
194
 
195
  // Javascript
196
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
197
+ echo '<script type="text/javascript">acf.post_id = 0;</script>';
 
 
 
 
198
 
199
 
200
  // add user js + css
core/controllers/input.php CHANGED
@@ -164,16 +164,13 @@ class acf_input
164
  // Javascript
165
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
166
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-ajax.js?ver=' . $this->parent->version . '" ></script>';
167
- echo '<script type="text/javascript">
168
- acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
169
- acf.post_id = ' . $post->ID . ';
170
- acf.admin_url = "' . admin_url() . '";
171
- </script>';
172
 
173
 
174
  // add user js + css
175
  do_action('acf_head-input');
176
 
 
177
  // get acf's
178
  $acfs = $this->parent->get_field_groups();
179
  if($acfs)
@@ -442,6 +439,26 @@ class acf_input
442
 
443
  function acf_head_input()
444
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  foreach($this->parent->fields as $field)
446
  {
447
  $field->admin_head();
164
  // Javascript
165
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
166
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-ajax.js?ver=' . $this->parent->version . '" ></script>';
167
+ echo '<script type="text/javascript">acf.post_id = ' . $post->ID . ';</script>';
 
 
 
 
168
 
169
 
170
  // add user js + css
171
  do_action('acf_head-input');
172
 
173
+
174
  // get acf's
175
  $acfs = $this->parent->get_field_groups();
176
  if($acfs)
439
 
440
  function acf_head_input()
441
  {
442
+
443
+ ?>
444
+ <script type="text/javascript">
445
+
446
+ // admin url
447
+ acf.admin_url = "<?php echo admin_url(); ?>";
448
+
449
+ // messages
450
+ acf.text.validation_error = "<?php _e("Validation Failed. One or more fields below are required.",'acf'); ?>";
451
+ acf.text.file_tb_title_add = "<?php _e("Add File to Field",'acf'); ?>";
452
+ acf.text.file_tb_title_edit = "<?php _e("Edit File",'acf'); ?>";
453
+ acf.text.image_tb_title_add = "<?php _e("Add Image to Field",'acf'); ?>";
454
+ acf.text.image_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
455
+ acf.text.relationship_max_alert = "<?php _e("Maximum values reached ( {max} values )",'acf'); ?>";
456
+ acf.text.gallery_tb_title_add = "<?php _e("Add Image to Gallery",'acf'); ?>";
457
+ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
458
+
459
+ </script>
460
+ <?php
461
+
462
  foreach($this->parent->fields as $field)
463
  {
464
  $field->admin_head();
core/controllers/options_page.php CHANGED
@@ -157,11 +157,7 @@ class acf_options_page
157
 
158
  // Javascript
159
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
160
- echo '<script type="text/javascript">
161
- acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
162
- acf.post_id = 0;
163
- acf.admin_url = "' . admin_url() . '";
164
- </script>';
165
 
166
 
167
  // add user js + css
157
 
158
  // Javascript
159
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
160
+ echo '<script type="text/javascript">acf.post_id = 0;</script>';
 
 
 
 
161
 
162
 
163
  // add user js + css
core/controllers/settings.php CHANGED
@@ -87,9 +87,9 @@ class acf_settings
87
  {
88
  $message = '<p>' . __("Flexible Content field deactivated",'acf') . '</p>';
89
  }
90
- elseif($field == "everything_fields")
91
  {
92
- $message = '<p>' . __("Everything Fields deactivated",'acf') . '</p>';
93
  }
94
 
95
  // show message on page
@@ -123,9 +123,9 @@ class acf_settings
123
  {
124
  $message = '<p>' . __("Flexible Content field activated",'acf') . '</p>';
125
  }
126
- elseif($field == "everything_fields")
127
  {
128
- $message = '<p>' . __("Everything Fields activated",'acf') . '</p>';
129
  }
130
  }
131
  else
@@ -229,6 +229,27 @@ if($action == ""):
229
  </form>
230
  </td>
231
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  <tr>
233
  <td><?php _e("Options Page",'acf'); ?></td>
234
  <td><?php echo $this->parent->is_field_unlocked('options_page') ? __("Active",'acf') : __("Inactive",'acf'); ?></td>
87
  {
88
  $message = '<p>' . __("Flexible Content field deactivated",'acf') . '</p>';
89
  }
90
+ elseif($field == "gallery")
91
  {
92
+ $message = '<p>' . __("Gallery field deactivated",'acf') . '</p>';
93
  }
94
 
95
  // show message on page
123
  {
124
  $message = '<p>' . __("Flexible Content field activated",'acf') . '</p>';
125
  }
126
+ elseif($field == "gallery")
127
  {
128
+ $message = '<p>' . __("Gallery field activated",'acf') . '</p>';
129
  }
130
  }
131
  else
229
  </form>
230
  </td>
231
  </tr>
232
+ <?php /*
233
+ <tr>
234
+ <td><?php _e("Gallery Field",'acf'); ?></td>
235
+ <td><?php echo $this->parent->is_field_unlocked('gallery') ? __("Active",'acf') : __("Inactive",'acf'); ?></td>
236
+ <td>
237
+ <form action="" method="post">
238
+ <?php if($this->parent->is_field_unlocked('gallery')){
239
+ echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->parent->get_license_key('gallery'),-4) .'</span>';
240
+ echo '<input type="hidden" name="acf_field_deactivate" value="gallery" />';
241
+ echo '<input type="submit" class="button" value="Deactivate" />';
242
+ }
243
+ else
244
+ {
245
+ echo '<input type="text" name="key" value="" />';
246
+ echo '<input type="hidden" name="acf_field_activate" value="gallery" />';
247
+ echo '<input type="submit" class="button" value="Activate" />';
248
+ } ?>
249
+ </form>
250
+ </td>
251
+ </tr>
252
+ */ ?>
253
  <tr>
254
  <td><?php _e("Options Page",'acf'); ?></td>
255
  <td><?php echo $this->parent->is_field_unlocked('options_page') ? __("Active",'acf') : __("Inactive",'acf'); ?></td>
core/fields/file.php CHANGED
@@ -45,7 +45,7 @@ class acf_File extends acf_Field
45
 
46
 
47
  // add message
48
- self.parent.acf.add_message('File Updated.', div);
49
 
50
 
51
  })(jQuery);
45
 
46
 
47
  // add message
48
+ self.parent.acf.add_message("<?php _e("File Updated.",'acf'); ?>", div);
49
 
50
 
51
  })(jQuery);
core/fields/gallery.php ADDED
@@ -0,0 +1,794 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Gallery Field
5
+ *
6
+ * @description:
7
+ * @created: 28/06/12
8
+ */
9
+
10
+ class acf_Gallery extends acf_Field
11
+ {
12
+
13
+ /*
14
+ * Constructer
15
+ *
16
+ * @description:
17
+ * @created: 5/07/12
18
+ */
19
+
20
+ function __construct($parent)
21
+ {
22
+ parent::__construct($parent);
23
+
24
+ $this->name = 'gallery';
25
+ $this->title = __("Gallery",'acf');
26
+
27
+
28
+ // actions
29
+ add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
30
+ add_action('acf_head-update_attachment-gallery', array($this, 'acf_head_update_attachment'));
31
+ add_action('wp_ajax_acf_get_gallery_list_data', array($this, 'acf_get_gallery_list_data'));
32
+ }
33
+
34
+
35
+ /*
36
+ * acf_get_gallery_list_data
37
+ *
38
+ * @description: AJAX call to get updated list data after an image is edited
39
+ * @created: 5/07/12
40
+ */
41
+
42
+ function acf_get_gallery_list_data()
43
+ {
44
+ // vars
45
+ $defaults = array(
46
+ 'attachment_id' => false,
47
+ );
48
+
49
+ $options = array_merge($defaults, $_GET);
50
+
51
+
52
+ // get attachment object
53
+ $attachment = get_post( $options['attachment_id'] );
54
+
55
+
56
+ // get fields
57
+ $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
58
+ $image_title = $attachment->post_title;
59
+ $caption = $attachment->post_excerpt;
60
+ $description = $attachment->post_content;
61
+
62
+ ?>
63
+ <table>
64
+ <tbody>
65
+ <tr>
66
+ <th><label><?php _e("Title",'acf'); ?>:</label></th>
67
+ <td><?php echo $image_title; ?></td>
68
+ </tr>
69
+ <tr>
70
+ <th><label><?php _e("Alternate Text",'acf'); ?>:</label></th>
71
+ <td><?php echo $alt; ?></td>
72
+ </tr>
73
+ <tr>
74
+ <th><label><?php _e("Caption",'acf'); ?>:</label></th>
75
+ <td><?php echo $caption; ?></td>
76
+ </tr>
77
+ <tr>
78
+ <th><label><?php _e("Description",'acf'); ?>:</label></th>
79
+ <td><?php echo $description; ?></td>
80
+ </tr>
81
+ </tbody>
82
+ </table>
83
+ <?php
84
+
85
+ // end ajax
86
+ die();
87
+ }
88
+
89
+
90
+ /*--------------------------------------------------------------------------------------
91
+ *
92
+ * create_options
93
+ * - this function is called from core/field_meta_box.php to create extra options
94
+ * for your field
95
+ *
96
+ * @params
97
+ * - $key (int) - the $_POST obejct key required to save the options to the field
98
+ * - $field (array) - the field object
99
+ *
100
+ * @author Elliot Condon
101
+ * @since 2.2.0
102
+ *
103
+ *-------------------------------------------------------------------------------------*/
104
+
105
+ function create_options($key, $field)
106
+ {
107
+ // vars
108
+ $defaults = array(
109
+ 'preview_size' => 'thumbnail',
110
+ );
111
+
112
+ $field = array_merge($defaults, $field);
113
+
114
+ ?>
115
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
116
+ <td class="label">
117
+ <label><?php _e("Preview Size",'acf'); ?></label>
118
+ <p class="description"><?php _e("Thumbnail is advised",'acf'); ?></p>
119
+ </td>
120
+ <td>
121
+ <?php
122
+
123
+ $image_sizes = $this->parent->get_all_image_sizes();
124
+
125
+ $this->parent->create_field(array(
126
+ 'type' => 'radio',
127
+ 'name' => 'fields['.$key.'][preview_size]',
128
+ 'value' => $field['preview_size'],
129
+ 'layout' => 'horizontal',
130
+ 'choices' => $image_sizes
131
+ ));
132
+
133
+ ?>
134
+ </td>
135
+ </tr>
136
+ <?php
137
+
138
+ }
139
+
140
+
141
+ function acf_head_update_attachment()
142
+ {
143
+ ?>
144
+ <script type="text/javascript">
145
+ (function($){
146
+
147
+ // vars
148
+ var div = self.parent.acf_edit_attachment,
149
+ attachment_id = div.attr('data-id');
150
+
151
+
152
+ // ajax find new list data
153
+ $.ajax({
154
+ url: ajaxurl,
155
+ data : {
156
+ 'action' : 'acf_get_gallery_list_data',
157
+ 'attachment_id' : attachment_id
158
+ },
159
+ cache: false,
160
+ dataType: "html",
161
+ success: function( html ) {
162
+
163
+
164
+ // validate
165
+ if(!html)
166
+ {
167
+ return false;
168
+ }
169
+
170
+
171
+ // update list-item html
172
+ div.find('.list-data').html( html );
173
+
174
+ }
175
+ });
176
+
177
+
178
+ // add message
179
+ self.parent.acf.add_message('<?php _e("Image Updated",'acf'); ?>.', div);
180
+
181
+
182
+ })(jQuery);
183
+ </script>
184
+ <?php
185
+ }
186
+
187
+
188
+ /*--------------------------------------------------------------------------------------
189
+ *
190
+ * create_field
191
+ * - this function is called on edit screens to produce the html for this field
192
+ *
193
+ * @author Elliot Condon
194
+ * @since 2.2.0
195
+ *
196
+ *-------------------------------------------------------------------------------------*/
197
+
198
+ function create_field($field)
199
+ {
200
+ // vars
201
+ $defaults = array(
202
+ 'value' => false,
203
+ 'preview_size' => 'thumbnail',
204
+ );
205
+
206
+ $field = array_merge($defaults, $field);
207
+
208
+ ?>
209
+ <div class="acf-gallery" data-preview_size="<?php echo $field['preview_size']; ?>">
210
+
211
+ <input type="hidden" name="<?php echo $field['name']; ?>" value="" />
212
+
213
+ <div class="thumbnails">
214
+ <div class="inner clearfix">
215
+ <?php if( $field['value'] ): foreach( $field['value'] as $attachment ):
216
+
217
+ $src = wp_get_attachment_image_src( $attachment['id'], $field['preview_size'] );
218
+ $src = $src[0];
219
+
220
+ ?>
221
+ <div class="thumbnail" data-id="<?php echo $attachment['id']; ?>">
222
+ <input type="hidden" name="<?php echo $field['name']; ?>[]" value="<?php echo $attachment['id']; ?>" />
223
+ <div class="inner clearfix">
224
+ <img src="<?php echo $src; ?>" alt="" />
225
+ <div class="list-data">
226
+ <table>
227
+ <tbody>
228
+ <tr>
229
+ <th><label><?php _e("Title",'acf'); ?>:</label></th>
230
+ <td><?php echo $attachment['title']; ?></td>
231
+ </tr>
232
+ <tr>
233
+ <th><label><?php _e("Alternate Text",'acf'); ?>:</label></th>
234
+ <td><?php echo $attachment['alt']; ?></td>
235
+ </tr>
236
+ <tr>
237
+ <th><label><?php _e("Caption",'acf'); ?>:</label></th>
238
+ <td><?php echo $attachment['caption']; ?></td>
239
+ </tr>
240
+ <tr>
241
+ <th><label><?php _e("Description",'acf'); ?>:</label></th>
242
+ <td><?php echo $attachment['description']; ?></td>
243
+ </tr>
244
+ </tbody>
245
+ </table>
246
+ </div>
247
+ </div>
248
+ <div class="hover">
249
+ <ul class="bl">
250
+ <li><a href="#" class="remove-image ir"><?php _e("Remove",'acf'); ?></a></li>
251
+ <li><a href="#" class="edit-image ir"><?php _e("Edit",'acf'); ?></a></li>
252
+ </ul>
253
+ </div>
254
+
255
+ </div>
256
+ <?php endforeach; endif; ?>
257
+ </div>
258
+ </div>
259
+
260
+ <div class="toolbar">
261
+ <ul class="hl clearfix">
262
+ <li class="add-image-li"><a class="add-image" href="#"><?php _e("Add Image",'acf'); ?></a><div class="divider"></div></li>
263
+ <li class="view-grid-li active"><div class="divider divider-left"></div><a class="ir view-grid" href="#"><?php _e("Grid",'acf'); ?></a><div class="divider"></div></li>
264
+ <li class="view-list-li"><a class="ir view-list" href="#"><?php _e("List",'acf'); ?></a><div class="divider"></div></li>
265
+ <li class="count-li right">
266
+ <span class="count" data-0="No images selected" data-1="1 image selected" data-2="{count} images selected"></span>
267
+ </li>
268
+ </ul>
269
+ </div>
270
+
271
+ <script type="text/html" class="tmpl-thumbnail">
272
+ <div class="thumbnail" data-id="0">
273
+ <input type="hidden" name="<?php echo $field['name']; ?>[]" value="" />
274
+ <div class="inner clearfix">
275
+ <img src="" alt="" />
276
+ <div class="list-data"><!-- Generated by AJAX --></div>
277
+ </div>
278
+ <div class="hover">
279
+ <ul class="bl">
280
+ <li><a href="#" class="remove-image ir"><?php _e("Remove",'acf'); ?></a></li>
281
+ <li><a href="#" class="edit-image ir"><?php _e("Edit",'acf'); ?></a></li>
282
+ </ul>
283
+ </div>
284
+
285
+ </div>
286
+ </script>
287
+
288
+ </div>
289
+ <?
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
+ /*--------------------------------------------------------------------------------------
312
+ *
313
+ * get_value
314
+ * - called from the edit page to get the value of your field. This function is useful
315
+ * if your field needs to collect extra data for your create_field() function.
316
+ *
317
+ * @params
318
+ * - $post_id (int) - the post ID which your value is attached to
319
+ * - $field (array) - the field object.
320
+ *
321
+ * @author Elliot Condon
322
+ * @since 2.2.0
323
+ *
324
+ *-------------------------------------------------------------------------------------*/
325
+
326
+ function get_value($post_id, $field)
327
+ {
328
+ // get value
329
+ $value = parent::get_value($post_id, $field);
330
+
331
+
332
+ // empty?
333
+ if( empty($value) )
334
+ {
335
+ return $value;
336
+ }
337
+
338
+
339
+ // find attachments (DISTINCT POSTS)
340
+ $attachments = get_posts(array(
341
+ 'post_type' => 'attachment',
342
+ 'numberposts' => -1,
343
+ 'post_status' => null,
344
+ 'post__in' => $value,
345
+ ));
346
+
347
+ $value = array();
348
+ foreach( $attachments as $attachment)
349
+ {
350
+ // create array to hold value data
351
+ $value[] = array(
352
+ 'id' => $attachment->ID,
353
+ 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
354
+ 'title' => $attachment->post_title,
355
+ 'caption' => $attachment->post_excerpt,
356
+ 'description' => $attachment->post_content,
357
+ );
358
+ }
359
+
360
+
361
+ /*
362
+ // format attachments
363
+ $ordered_attachments = array();
364
+ foreach( $attachments as $attachment )
365
+ {
366
+ $ordered_attachments[ $attachment->ID ] = $attachment;
367
+ }
368
+
369
+
370
+ // update value with corisponding attachments
371
+ foreach( $value as $k => $v)
372
+ {
373
+ // get the attachment onject for this value (attachment id)
374
+ $attachment = $ordered_attachments[ $v ];
375
+
376
+ // create array to hold value data
377
+ $value[ $k ] = array(
378
+ 'id' => $attachment->ID,
379
+ 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
380
+ 'title' => $attachment->post_title,
381
+ 'caption' => $attachment->post_excerpt,
382
+ 'description' => $attachment->post_content,
383
+ );
384
+ }
385
+
386
+ */
387
+
388
+ // return value
389
+ return $value;
390
+ }
391
+
392
+
393
+ /*--------------------------------------------------------------------------------------
394
+ *
395
+ * get_value_for_api
396
+ * - called from your template file when using the API functions (get_field, etc).
397
+ * This function is useful if your field needs to format the returned value
398
+ *
399
+ * @params
400
+ * - $post_id (int) - the post ID which your value is attached to
401
+ * - $field (array) - the field object.
402
+ *
403
+ * @author Elliot Condon
404
+ * @since 3.0.0
405
+ *
406
+ *-------------------------------------------------------------------------------------*/
407
+
408
+ function get_value_for_api($post_id, $field)
409
+ {
410
+ // get value
411
+ $value = $this->get_value($post_id, $field);
412
+
413
+
414
+ // find all image sizes
415
+ $image_sizes = get_intermediate_image_sizes();
416
+
417
+
418
+ if( $value )
419
+ {
420
+ foreach( $value as $k => $v )
421
+ {
422
+ // full url
423
+ $value[$k]['url'] = wp_get_attachment_url( $v['id'] );
424
+
425
+ // sizes
426
+ if( $image_sizes )
427
+ {
428
+ $value[$k]['sizes'] = array();
429
+
430
+ foreach( $image_sizes as $image_size )
431
+ {
432
+ // find src
433
+ $src = wp_get_attachment_image_src( $v['id'], $image_size );
434
+
435
+ // add src
436
+ $value[$k]['sizes'][$image_size] = $src[0];
437
+ }
438
+ // foreach( $image_sizes as $image_size )
439
+ }
440
+ // if( $image_sizes )
441
+ }
442
+ // foreach( $value as $k => $v )
443
+ }
444
+ // if( $value )
445
+
446
+
447
+ // return value
448
+ return $value;
449
+
450
+ }
451
+
452
+
453
+ /*
454
+ * popup_head
455
+ *
456
+ * @description:
457
+ * @since 3.2.8
458
+ * @created: 6/07/12
459
+ */
460
+
461
+ function popup_head()
462
+ {
463
+ // $_GET is required
464
+ if( ! isset($_GET) )
465
+ {
466
+ return;
467
+ }
468
+
469
+
470
+ // options
471
+ $defaults = array(
472
+ 'acf_type' => '',
473
+ 'acf_gallery_id' => '',
474
+ 'preview_size' => 'thumbnail',
475
+ 'tab' => 'type',
476
+ );
477
+
478
+ $options = array_merge($defaults, $_GET);
479
+
480
+
481
+ // validate
482
+ if( $options['acf_type'] != 'gallery' )
483
+ {
484
+ return;
485
+ }
486
+
487
+
488
+ ?><style type="text/css">
489
+ #media-upload-header #sidemenu li#tab-type_url,
490
+ #media-upload-header #sidemenu li#tab-gallery,
491
+ #media-items .media-item a.toggle,
492
+ #media-items .media-item tr.image-size,
493
+ #media-items .media-item tr.align,
494
+ #media-items .media-item tr.url,
495
+ #media-items .media-item .slidetoggle {
496
+ display: none !important;
497
+ }
498
+
499
+ #media-items .media-item {
500
+ position: relative;
501
+ overflow: hidden;
502
+ }
503
+
504
+ #media-items .media-item .acf-checkbox {
505
+ float: left;
506
+ margin: 28px 10px 0;
507
+ }
508
+
509
+ #media-items .media-item .pinkynail {
510
+ max-width: 64px;
511
+ max-height: 64px;
512
+ display: block !important;
513
+ margin: 2px;
514
+ }
515
+
516
+ #media-items .media-item .filename.new {
517
+ min-height: 0;
518
+ padding: 20px 10px 10px 10px;
519
+ line-height: 15px;
520
+ }
521
+
522
+ #media-items .media-item .title {
523
+ line-height: 14px;
524
+ }
525
+
526
+ #media-items .media-item .acf-select {
527
+ float: right;
528
+ margin: 22px 12px 0 10px;
529
+ }
530
+
531
+ #media-upload .ml-submit {
532
+ display: none !important;
533
+ }
534
+
535
+ #media-upload .acf-submit {
536
+ margin: 1em 0;
537
+ padding: 1em 0;
538
+ position: relative;
539
+ overflow: hidden;
540
+ display: none; /* default is hidden */
541
+ }
542
+
543
+ #media-upload .acf-submit a {
544
+ float: left;
545
+ margin: 0 10px 0 0;
546
+ }
547
+
548
+ .acf-message-wrapper .message {
549
+ margin: 2px 2px 0;
550
+ }
551
+
552
+ </style>
553
+ <script type="text/javascript">
554
+ (function($){
555
+
556
+
557
+ // global vars
558
+ var gallery,
559
+ tmpl_thumbnail;
560
+
561
+
562
+
563
+ /*
564
+ * Select Image
565
+ *
566
+ * @created : 28/03/2012
567
+ */
568
+
569
+ $('#media-items .media-item a.acf-select').live('click', function(){
570
+
571
+ var attachment_id = $(this).attr('href'),
572
+ div = $(this).closest('.media-item');
573
+
574
+
575
+ // does this image already exist in the gallery?
576
+ if( gallery.find('.thumbnail[data-id="' + attachment_id + '"]').length > 0 )
577
+ {
578
+ alert("<?php _e("Image already exists in gallery",'acf'); ?>");
579
+ return false;
580
+ }
581
+
582
+
583
+ // show added message
584
+ self.parent.acf.add_message('<?php _e("Image Added",'acf'); ?>.', div);
585
+
586
+
587
+ // add image
588
+ add_image( attachment_id );
589
+
590
+
591
+ return false;
592
+
593
+ });
594
+
595
+
596
+ // edit toggle
597
+ $('#media-items .media-item a.acf-toggle-edit').live('click', function(){
598
+
599
+ if( $(this).hasClass('active') )
600
+ {
601
+ $(this).removeClass('active');
602
+ $(this).closest('.media-item').find('.slidetoggle').attr('style', 'display: none !important');
603
+ return false;
604
+ }
605
+ else
606
+ {
607
+ $(this).addClass('active');
608
+ $(this).closest('.media-item').find('.slidetoggle').attr('style', 'display: table !important');
609
+ return false;
610
+ }
611
+
612
+ });
613
+
614
+
615
+ // set a interval function to add buttons to media items
616
+ function acf_add_buttons()
617
+ {
618
+
619
+ // add buttons to media items
620
+ $('#media-items .media-item:not(.acf-active)').each(function(){
621
+
622
+ // needs attachment ID
623
+ if($(this).children('input[id*="type-of-"]').length == 0){ return false; }
624
+
625
+ // only once!
626
+ $(this).addClass('acf-active');
627
+
628
+ // find id
629
+ var id = $(this).children('input[id*="type-of-"]').attr('id').replace('type-of-', '');
630
+
631
+ // Add edit button
632
+ $(this).find('.filename.new').append('<br /><a href="#" class="acf-toggle-edit">Edit</a>');
633
+
634
+ // Add select button
635
+ $(this).find('.filename.new').before('<a href="' + id + '" class="button acf-select"><?php _e("Add Image",'acf'); ?></a>');
636
+
637
+ // add save changes button
638
+ $(this).find('tr.submit input.button').hide().before('<input type="submit" value="<?php _e("Update Image",'acf'); ?>" class="button savebutton" />');
639
+
640
+
641
+ });
642
+ }
643
+ <?php
644
+
645
+ // run the acf_add_buttons ever 500ms when on the image upload tab
646
+ if($options['tab'] == 'type'): ?>
647
+ var acf_t = setInterval(function(){
648
+ acf_add_buttons();
649
+ }, 500);
650
+ <?php endif; ?>
651
+
652
+
653
+ // add acf input filters to allow for tab navigation
654
+ $(document).ready(function(){
655
+
656
+ setTimeout(function(){
657
+ acf_add_buttons();
658
+ }, 1);
659
+
660
+
661
+ $('form#filter').each(function(){
662
+
663
+ $(this).append('<input type="hidden" name="acf_preview_size" value="<?php echo $options['preview_size']; ?>" />');
664
+ $(this).append('<input type="hidden" name="acf_type" value="gallery" />');
665
+
666
+ });
667
+
668
+ $('form#image-form, form#library-form').each(function(){
669
+
670
+ var action = $(this).attr('action');
671
+ action += "&acf_type=gallery&acf_preview_size=<?php $options['preview_size']; ?>";
672
+ $(this).attr('action', action);
673
+
674
+ });
675
+ });
676
+
677
+
678
+ /*
679
+ * add_image
680
+ *
681
+ * @description:
682
+ * @created: 2/07/12
683
+ */
684
+
685
+ function add_image( attachment_id )
686
+ {
687
+
688
+ $.ajax({
689
+ url: ajaxurl,
690
+ data : {
691
+ action: 'acf_get_preview_image',
692
+ id: attachment_id,
693
+ preview_size : "<?php echo $options['preview_size']; ?>"
694
+ },
695
+ cache: false,
696
+ dataType: "json",
697
+ success: function( json ) {
698
+
699
+
700
+ // validate
701
+ if(!json)
702
+ {
703
+ return;
704
+ }
705
+
706
+
707
+ // get item
708
+ var item = json[0];
709
+
710
+
711
+ // create thumbnail div
712
+ var div = $(tmpl_thumbnail);
713
+
714
+
715
+ // add id refernece to later replace this div with the image
716
+ div.attr('data-id', item.id);
717
+ div.find('input[type="hidden"]').val(item.id);
718
+
719
+
720
+ // add image src
721
+ div.find('img').attr('src', item.url);
722
+
723
+
724
+ // replace loading with thumbnail
725
+ gallery.find('.thumbnails > .inner').append( div );
726
+
727
+
728
+ // update gallery count
729
+ self.parent.acf.update_gallery_count( gallery );
730
+
731
+
732
+ // validation
733
+ div.closest('.field').removeClass('error');
734
+
735
+
736
+ // ajax find new list data
737
+ $.ajax({
738
+ url: ajaxurl,
739
+ data : {
740
+ 'action' : 'acf_get_gallery_list_data',
741
+ 'attachment_id' : item.id
742
+ },
743
+ cache: false,
744
+ dataType: "html",
745
+ success: function( html ) {
746
+
747
+
748
+ // validate
749
+ if(!html)
750
+ {
751
+ return false;
752
+ }
753
+
754
+
755
+ // update list-item html
756
+ div.find('.list-data').html( html );
757
+
758
+ }
759
+ // success: function( html ) {
760
+
761
+ });
762
+ // $.ajax({
763
+ }
764
+ // success: function( json ) {
765
+ });
766
+ // $.ajax({
767
+ }
768
+
769
+
770
+ /*
771
+ * Document Ready
772
+ *
773
+ * @description:
774
+ * @created: 2/07/12
775
+ */
776
+
777
+ $(document).ready(function(){
778
+
779
+
780
+ // vars
781
+ gallery = self.parent.acf_div;
782
+ tmpl_thumbnail = gallery.find('.tmpl-thumbnail').html();
783
+
784
+
785
+ });
786
+
787
+ })(jQuery);
788
+ </script><?php
789
+
790
+ }
791
+
792
+ }
793
+
794
+ ?>
core/fields/image.php CHANGED
@@ -46,7 +46,7 @@ class acf_Image extends acf_Field
46
 
47
 
48
  // add message
49
- self.parent.acf.add_message('Image Updated.', div);
50
 
51
 
52
  })(jQuery);
@@ -183,8 +183,8 @@ class acf_Image extends acf_Field
183
  <div class="has-image">
184
  <div class="hover">
185
  <ul class="bl">
186
- <li><a class="remove-image ir" href="#">Remove</a></li>
187
- <li><a class="edit-image ir" href="#">Edit</a></li>
188
  </ul>
189
  </div>
190
  <img src="<?php echo $file_src; ?>" alt=""/>
@@ -210,8 +210,12 @@ class acf_Image extends acf_Field
210
  function create_options($key, $field)
211
  {
212
  // vars
213
- $field['save_format'] = isset($field['save_format']) ? $field['save_format'] : 'url';
214
- $field['preview_size'] = isset($field['preview_size']) ? $field['preview_size'] : 'thumbnail';
 
 
 
 
215
 
216
  ?>
217
  <tr class="field_option field_option_<?php echo $this->name; ?>">
@@ -240,20 +244,7 @@ class acf_Image extends acf_Field
240
  <td>
241
  <?php
242
 
243
- $image_sizes = array(
244
- 'thumbnail' => __("Thumbnail",'acf'),
245
- 'medium' => __("Medium",'acf'),
246
- 'large' => __("Large",'acf'),
247
- 'full' => __("Full",'acf')
248
- );
249
-
250
- foreach(get_intermediate_image_sizes() as $size)
251
- {
252
- if (!isset($image_sizes[$size]))
253
- {
254
- $image_sizes[$size] = $size;
255
- }
256
- }
257
 
258
  $this->parent->create_field(array(
259
  'type' => 'radio',
@@ -365,15 +356,7 @@ class acf_Image extends acf_Field
365
 
366
  </style>
367
  <script type="text/javascript">
368
- (function($){
369
-
370
- /*
371
- * Vars
372
- */
373
-
374
- // generate the preview size (150x150)
375
- var preview_size = "<?php echo get_option($preview_size . '_size_w'); ?>x<?php echo get_option($preview_size . '_size_h'); ?>";
376
-
377
 
378
  /*
379
  * Select Image
46
 
47
 
48
  // add message
49
+ self.parent.acf.add_message("<?php _e("Image Updated.",'acf'); ?>", div);
50
 
51
 
52
  })(jQuery);
183
  <div class="has-image">
184
  <div class="hover">
185
  <ul class="bl">
186
+ <li><a class="remove-image ir" href="#"><?php _e("Remove",'acf'); ?></a></li>
187
+ <li><a class="edit-image ir" href="#"><?php _e("Edit",'acf'); ?></a></li>
188
  </ul>
189
  </div>
190
  <img src="<?php echo $file_src; ?>" alt=""/>
210
  function create_options($key, $field)
211
  {
212
  // vars
213
+ $defaults = array(
214
+ 'save_format' => 'url',
215
+ 'preview_size' => 'thumbnail',
216
+ );
217
+
218
+ $field = array_merge($defaults, $field);
219
 
220
  ?>
221
  <tr class="field_option field_option_<?php echo $this->name; ?>">
244
  <td>
245
  <?php
246
 
247
+ $image_sizes = $this->parent->get_all_image_sizes();
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
  $this->parent->create_field(array(
250
  'type' => 'radio',
356
 
357
  </style>
358
  <script type="text/javascript">
359
+ (function($){
 
 
 
 
 
 
 
 
360
 
361
  /*
362
  * Select Image
core/fields/page_link.php CHANGED
@@ -84,7 +84,7 @@ class acf_Page_link extends acf_Field
84
  'post_type' => $post_type,
85
  'sort_column' => 'menu_order',
86
  'order' => 'ASC',
87
- 'post_status' => array('publish', 'private', 'draft'),
88
  'suppress_filters' => false,
89
  //'meta_key' => $field['meta_key'],
90
  //'meta_value' => $field['meta_value'],
84
  'post_type' => $post_type,
85
  'sort_column' => 'menu_order',
86
  'order' => 'ASC',
87
+ 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
88
  'suppress_filters' => false,
89
  //'meta_key' => $field['meta_key'],
90
  //'meta_value' => $field['meta_value'],
core/fields/post_object.php CHANGED
@@ -78,7 +78,7 @@ class acf_Post_object extends acf_Field
78
  'post_type' => $post_type,
79
  'sort_column' => 'menu_order',
80
  'order' => 'ASC',
81
- 'post_status' => array('publish', 'private', 'draft'),
82
  'suppress_filters' => false,
83
  //'meta_key' => $field['meta_key'],
84
  //'meta_value' => $field['meta_value'],
@@ -92,7 +92,7 @@ class acf_Post_object extends acf_Field
92
  'post_type' => $post_type,
93
  'orderby' => 'title',
94
  'order' => 'ASC',
95
- 'post_status' => array('publish', 'private', 'draft'),
96
  'suppress_filters' => false,
97
  //'meta_key' => $field['meta_key'],
98
  //'meta_value' => $field['meta_value'],
78
  'post_type' => $post_type,
79
  'sort_column' => 'menu_order',
80
  'order' => 'ASC',
81
+ 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
82
  'suppress_filters' => false,
83
  //'meta_key' => $field['meta_key'],
84
  //'meta_value' => $field['meta_value'],
92
  'post_type' => $post_type,
93
  'orderby' => 'title',
94
  'order' => 'ASC',
95
+ 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
96
  'suppress_filters' => false,
97
  //'meta_key' => $field['meta_key'],
98
  //'meta_value' => $field['meta_value'],
core/fields/relationship.php CHANGED
@@ -80,7 +80,7 @@ class acf_Relationship extends acf_Field
80
  'post_type' => $field['post_type'],
81
  'orderby' => 'title',
82
  'order' => 'ASC',
83
- 'post_status' => array('publish', 'private', 'draft', 'inherit'),
84
  'suppress_filters' => false,
85
  //'meta_key' => $field['meta_key'],
86
  //'meta_value' => $field['meta_value'],
80
  'post_type' => $field['post_type'],
81
  'orderby' => 'title',
82
  'order' => 'ASC',
83
+ 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
84
  'suppress_filters' => false,
85
  //'meta_key' => $field['meta_key'],
86
  //'meta_value' => $field['meta_value'],
core/fields/repeater.php CHANGED
@@ -58,121 +58,170 @@ class acf_Repeater extends acf_Field
58
  function create_field($field)
59
  {
60
  // vars
61
- $row_limit = ( isset($field['row_limit']) && is_numeric($field['row_limit']) ) ? $field['row_limit'] : 999;
62
- $layout = isset($field['layout']) ? $field['layout'] : 'table';
63
- $sub_fields = isset($field['sub_fields']) ? $field['sub_fields'] : array();
64
- $button_label = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Add Row",'acf');
 
 
 
 
65
 
 
66
 
67
- // add clone field
68
- if( !$field['value'] )
 
 
 
 
 
 
69
  {
70
- $field['value'] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
72
 
73
- if($row_limit == 1 && count($field['value']) == 0)
 
 
74
  {
75
- $field['value'][] = array();
 
 
 
 
 
 
76
  }
77
 
 
78
  // setup values for row clone
79
  $field['value'][999] = array();
80
- foreach($sub_fields as $sub_field)
81
  {
82
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
83
  $field['value'][999][$sub_field['name']] = $sub_value;
84
  }
85
 
86
 
87
- ?>
88
- <div class="repeater" data-row_limit="<?php echo $row_limit; ?>">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- <table class="widefat <?php if($layout == 'row'): ?>row_layout<?php endif; ?>">
91
- <?php if($layout == 'table'): ?>
92
- <thead>
93
- <tr><?php
94
-
95
- if($row_limit > 1): ?><th class="order"></th><?php endif;
96
-
97
- foreach($sub_fields as $sub_field_i => $sub_field):
98
- ?><th class="<?php echo $sub_field['name']; ?>" <?php if($sub_field_i != 0): ?>style="width:<?php echo 95/count($sub_fields); ?>%;"<?php endif; ?>><span><?php echo $sub_field['label']; ?></span></th><?php
99
- endforeach;
100
-
101
- if($row_limit > 1): ?><th class="remove"></th><?php endif;
102
-
103
- ?></tr>
104
- </thead>
105
- <?php endif; ?>
106
- <tbody>
107
- <?php if( $field['value'] ): foreach($field['value'] as $i => $value):?>
108
- <tr class="<?php echo ($i == 999) ? "row-clone" : "row"; ?>">
109
-
110
- <?php if($row_limit > 1): ?>
111
- <td class="order">
112
- <?php echo $i+1; ?>
113
- </td>
114
- <?php endif; ?>
115
-
116
- <?php if($layout == 'row'): ?><td><?php endif; ?>
117
-
118
- <?php foreach($sub_fields as $j => $sub_field):?>
119
-
120
- <?php if($layout == 'table'): ?>
121
- <td>
122
- <?php else: ?>
123
- <div class="row-layout-field">
124
- <p class="label">
125
- <label><?php echo $sub_field['label']; ?></label>
126
- <?php
127
-
128
- if(!isset($sub_field['instructions']))
129
- $sub_field['instructions'] = "";
130
-
131
- echo $sub_field['instructions'];
132
-
133
- ?>
134
- </p>
135
- <?php endif; ?>
136
-
137
- <?php
138
- // add value
139
- $sub_field['value'] = isset($value[$sub_field['name']]) ? $value[$sub_field['name']] : '';
140
-
141
- // add name
142
- $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
143
-
144
- // create field
145
- $this->parent->create_field($sub_field);
146
- ?>
147
-
148
- <?php if($layout == 'table'): ?>
149
- </td>
150
- <?php else: ?>
151
- </div>
152
- <?php endif; ?>
153
 
154
- <?php endforeach; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
- <?php if($layout == 'row'): ?></td><?php endif; ?>
 
157
 
158
- <?php if($row_limit > 1): ?>
159
- <td class="remove"><a class="add-row add-row-before" href="javascript:;"></a><a class="remove-row" href="javascript:;"></a></td>
160
- <?php endif; ?>
161
- </tr>
162
- <?php endforeach; endif; ?>
163
- </tbody>
164
- </table>
165
- <?php if($row_limit > 1): ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
- <ul class="hl clearfix repeater-footer">
168
- <li class="right">
169
- <a href="javascript:;" class="add-row-end acf-button"><?php echo $button_label; ?></a>
170
- </li>
171
- </ul>
172
 
173
- <?php endif; ?>
174
- </div>
175
- <?php
176
  }
177
 
178
 
@@ -191,10 +240,20 @@ class acf_Repeater extends acf_Field
191
  {
192
  // vars
193
  $fields_names = array();
194
- $field['row_limit'] = isset($field['row_limit']) ? $field['row_limit'] : '';
195
- $field['layout'] = isset($field['layout']) ? $field['layout'] : 'table';
196
- $field['sub_fields'] = isset($field['sub_fields']) ? $field['sub_fields'] : array();
197
- $field['button_label'] = (isset($field['button_label']) && $field['button_label'] != "") ? $field['button_label'] : __("Add Row",'acf');
 
 
 
 
 
 
 
 
 
 
198
 
199
 
200
  // add clone field
@@ -211,8 +270,6 @@ class acf_Repeater extends acf_Field
211
  {
212
  $fields_names[$f->name] = $f->title;
213
  }
214
- //unset($fields_names['repeater']);
215
- //unset($fields_names['flexible_content']);
216
 
217
  ?>
218
  <tr class="field_option field_option_<?php echo $this->name; ?>">
@@ -350,10 +407,23 @@ class acf_Repeater extends acf_Field
350
  </div>
351
  </td>
352
  </tr>
353
-
354
  <tr class="field_option field_option_<?php echo $this->name; ?>">
355
  <td class="label">
356
- <label><?php _e("Row Limit",'acf'); ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  </td>
358
  <td>
359
  <?php
58
  function create_field($field)
59
  {
60
  // vars
61
+ $defaults = array(
62
+ 'row_limit' => 0,
63
+ 'row_min' => 0,
64
+ 'layout' => 'table',
65
+ 'sub_fields' => array(),
66
+ 'button_label' => __("Add Row",'acf'),
67
+ 'value' => array(),
68
+ );
69
 
70
+ $field = array_merge($defaults, $field);
71
 
72
+
73
+ // validate types
74
+ $field['row_limit'] = (int) $field['row_limit'];
75
+ $field['row_min'] = (int) $field['row_min'];
76
+
77
+
78
+ // row limit = 0?
79
+ if( $field['row_limit'] == 0 )
80
  {
81
+ $field['row_limit'] = 999;
82
+ }
83
+
84
+
85
+ // min rows
86
+ if( $field['row_min'] > count($field['value']) )
87
+ {
88
+ for( $i = 0; $i < $field['row_min']; $i++ )
89
+ {
90
+ if( ! isset($field['value'][$i]) )
91
+ {
92
+ $field['value'][$i] = array();
93
+ }
94
+ }
95
  }
96
 
97
+
98
+ // max rows
99
+ if( $field['row_limit'] < count($field['value']) )
100
  {
101
+ for( $i = 0; $i < count($field['value']); $i++ )
102
+ {
103
+ if( $i >= $field['row_limit'] )
104
+ {
105
+ unset( $field['value'][$i] );
106
+ }
107
+ }
108
  }
109
 
110
+
111
  // setup values for row clone
112
  $field['value'][999] = array();
113
+ foreach( $field['sub_fields'] as $sub_field)
114
  {
115
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
116
  $field['value'][999][$sub_field['name']] = $sub_value;
117
  }
118
 
119
 
120
+ ?>
121
+ <div class="repeater" data-min_rows="<?php echo $field['row_min']; ?>" data-max_rows="<?php echo $field['row_limit']; ?>">
122
+ <table class="widefat <?php if( $field['layout'] == 'row' ): ?>row_layout<?php endif; ?>">
123
+ <?php if( $field['layout'] == 'table' ): ?>
124
+ <thead>
125
+ <tr><?php
126
+
127
+ if( $field['row_limit'] > 1 ): ?><th class="order"></th><?php endif;
128
+
129
+ foreach( $field['sub_fields'] as $sub_field_i => $sub_field):
130
+ ?><th class="<?php echo $sub_field['name']; ?>" <?php if($sub_field_i != 0): ?>style="width:<?php echo 95/count($sub_fields); ?>%;"<?php endif; ?>><span><?php echo $sub_field['label']; ?></span></th><?php
131
+ endforeach;
132
+
133
+ if( $field['row_min'] < $field['row_limit'] ): ?><th class="remove"></th><?php endif;
134
+
135
+ ?></tr>
136
+ </thead>
137
+ <?php endif; ?>
138
+ <tbody>
139
+ <?php if( $field['value'] ): foreach($field['value'] as $i => $value):
140
+
141
+ ?><tr class="<?php echo ($i == 999) ? "row-clone" : "row"; ?>"><?php
142
+
143
+ if( $field['row_limit'] > 1 ):
144
+ ?><td class="order"><?php echo $i+1; ?></td><?php
145
+ endif;
146
+
147
+ if( $field['layout'] == 'row' ): ?><td><?php endif;
148
+
149
+
150
+ foreach( $field['sub_fields'] as $j => $sub_field ):
151
 
152
+ if( $field['layout'] == 'table'):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
+ ?><td><?php
155
+
156
+ else:
157
+
158
+ ?><div class="row-layout-field">
159
+ <p class="label">
160
+ <label><?php echo $sub_field['label']; ?></label><?php
161
+
162
+ if(!isset($sub_field['instructions']))
163
+ {
164
+ $sub_field['instructions'] = "";
165
+ }
166
+
167
+ echo $sub_field['instructions'];
168
+
169
+ ?></p><?php
170
+
171
+ endif;
172
+
173
+ // add value
174
+ $sub_field['value'] = isset($value[$sub_field['name']]) ? $value[$sub_field['name']] : '';
175
 
176
+ // add name
177
+ $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
178
 
179
+ // create field
180
+ $this->parent->create_field($sub_field);
181
+
182
+
183
+ if( $field['layout'] == 'table' ):
184
+
185
+ ?></td><?php
186
+
187
+ else:
188
+
189
+ ?></div><?php
190
+
191
+ endif;
192
+
193
+ endforeach;
194
+
195
+
196
+ if( $field['layout'] == 'row' ): ?></td><?php endif;
197
+
198
+ if( $field['row_min'] < $field['row_limit'] ):
199
+
200
+ ?><td class="remove">
201
+ <a class="add-row add-row-before" href="javascript:;"></a>
202
+ <a class="remove-row" href="javascript:;"></a>
203
+ </td><?php
204
+
205
+ endif;
206
+
207
+ ?></tr><?php
208
+
209
+ endforeach; endif;
210
+
211
+ ?>
212
+ </tbody>
213
+ </table>
214
+ <?php if( $field['row_min'] < $field['row_limit'] ): ?>
215
 
216
+ <ul class="hl clearfix repeater-footer">
217
+ <li class="right">
218
+ <a href="javascript:;" class="add-row-end acf-button"><?php echo $field['button_label']; ?></a>
219
+ </li>
220
+ </ul>
221
 
222
+ <?php endif; ?>
223
+ </div>
224
+ <?php
225
  }
226
 
227
 
240
  {
241
  // vars
242
  $fields_names = array();
243
+ $defaults = array(
244
+ 'row_limit' => '',
245
+ 'row_min' => '0',
246
+ 'layout' => 'table',
247
+ 'sub_fields' => array(),
248
+ 'button_label' => __("Add Row",'acf'),
249
+ 'value' => array(),
250
+ );
251
+
252
+ $field = array_merge($defaults, $field);
253
+
254
+
255
+ // validate types
256
+ $field['row_min'] = (int) $field['row_min'];
257
 
258
 
259
  // add clone field
270
  {
271
  $fields_names[$f->name] = $f->title;
272
  }
 
 
273
 
274
  ?>
275
  <tr class="field_option field_option_<?php echo $this->name; ?>">
407
  </div>
408
  </td>
409
  </tr>
 
410
  <tr class="field_option field_option_<?php echo $this->name; ?>">
411
  <td class="label">
412
+ <label><?php _e("Minimum Rows",'acf'); ?></label>
413
+ </td>
414
+ <td>
415
+ <?php
416
+ $this->parent->create_field(array(
417
+ 'type' => 'text',
418
+ 'name' => 'fields['.$key.'][row_min]',
419
+ 'value' => $field['row_min'],
420
+ ));
421
+ ?>
422
+ </td>
423
+ </tr>
424
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
425
+ <td class="label">
426
+ <label><?php _e("Maximum Rows",'acf'); ?></label>
427
  </td>
428
  <td>
429
  <?php
css/input.css CHANGED
@@ -953,3 +953,282 @@ ul.checkbox_list {
953
  width: auto;
954
  }
955
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
953
  width: auto;
954
  }
955
 
956
+
957
+ /*---------------------------------------------------------------------------------------------
958
+ *
959
+ * Gallery Field
960
+ *
961
+ *---------------------------------------------------------------------------------------------*/
962
+
963
+ .acf-gallery {
964
+ position: relative;
965
+ overflow: hidden;
966
+ border: #DFDFDF solid 1px;
967
+ border-radius: 3px;
968
+ box-shadow: #f9f9f9 0 1px 0;
969
+ }
970
+
971
+ .acf-gallery .thumbnails {
972
+ background: #ececec;
973
+ min-height: 400px;
974
+ margin: 0 0 0 0;
975
+
976
+ position: relative;
977
+ z-index: 1;
978
+
979
+ -webkit-transition: all 0.5s ease-out; /* Saf3.2+, Chrome */
980
+ -moz-transition: all 0.5s ease-out; /* FF4+ */
981
+ -o-transition: all 0.5s ease-out; /* Opera 10.5+ */
982
+ transition: all 0.5s ease-out;
983
+
984
+ }
985
+
986
+ .acf-gallery .thumbnails .inner {
987
+ padding: 10px;
988
+ position: relative;
989
+ }
990
+
991
+ .acf-gallery .thumbnail {
992
+ margin: 10px;
993
+ position: relative;
994
+ float: left;
995
+
996
+ background: #fff;
997
+ box-shadow: 0 1px 2px rgba(0,0,0,0.2);
998
+
999
+ cursor: move;
1000
+ }
1001
+
1002
+ .acf-gallery .thumbnail .inner {
1003
+ padding: 5px;
1004
+ }
1005
+
1006
+ .acf-gallery .thumbnail img {
1007
+ display: block;
1008
+ }
1009
+
1010
+ .acf-gallery .thumbnail.ui-sortable-placeholder {
1011
+ visibility: visible !important;
1012
+ background: transparent;
1013
+ box-shadow: none;
1014
+ border: #DFDFDF dashed 2px;
1015
+ border-radius: 3px;
1016
+ }
1017
+
1018
+
1019
+ /*
1020
+ * Toolbar
1021
+ */
1022
+
1023
+ .acf-gallery .toolbar {
1024
+ border-top: #DFDFDF solid 1px;
1025
+
1026
+ background-color: #F1F1F1;
1027
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#F9F9F9), to(#ECECEC)); /* Saf4+, Chrome */
1028
+ background-image: -webkit-linear-gradient(top, #F9F9F9, #ECECEC); /* Chrome 10+, Saf5.1+, iOS 5+ */
1029
+ background-image: -moz-linear-gradient(top, #F9F9F9, #ECECEC); /* FF3.6+ */
1030
+ background-image: -o-linear-gradient(top, #F9F9F9, #ECECEC); /* Opera 11.10+ */
1031
+ background-image: linear-gradient(to bottom, #F9F9F9, #ECECEC);
1032
+
1033
+ }
1034
+
1035
+ .acf-gallery .toolbar li {
1036
+ font-size: 12px;
1037
+ line-height: 1em;
1038
+ position: relative;
1039
+ }
1040
+
1041
+ .acf-gallery .toolbar li:hover,
1042
+ .acf-gallery .toolbar li.active {
1043
+ background-color: #F9F9F9;
1044
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#ECECEC), to(#F9F9F9)); /* Saf4+, Chrome */
1045
+ background-image: -webkit-linear-gradient(top, #ECECEC, #F9F9F9); /* Chrome 10+, Saf5.1+, iOS 5+ */
1046
+ background-image: -moz-linear-gradient(top, #ECECEC, #F9F9F9); /* FF3.6+ */
1047
+ background-image: -o-linear-gradient(top, #ECECEC, #F9F9F9); /* Opera 11.10+ */
1048
+ background-image: linear-gradient(to bottom, #ECECEC, #F9F9F9);
1049
+ }
1050
+
1051
+ .acf-gallery .toolbar li.count-li:hover {
1052
+ background: transparent;
1053
+ }
1054
+
1055
+ .acf-gallery .toolbar li a,
1056
+ .acf-gallery .toolbar li span {
1057
+ display: block;
1058
+ padding: 1em;
1059
+
1060
+ color: #333333;
1061
+ text-shadow: #fff 0 1px 0;
1062
+
1063
+ text-decoration: none;
1064
+ }
1065
+
1066
+ .acf-gallery .toolbar li span {
1067
+ color: #8d8d8d;
1068
+ }
1069
+
1070
+ .acf-gallery .toolbar li .divider {
1071
+ position: absolute;
1072
+ height: 100%;
1073
+ width: 1px;
1074
+ background: #dfdfdf;
1075
+ border-right: #fff solid 1px;
1076
+
1077
+ top: 0;
1078
+ right: 0;
1079
+ margin-right: -1px;
1080
+ }
1081
+
1082
+ .acf-gallery .toolbar li .divider-left {
1083
+ right: auto;
1084
+ margin-right: 0;
1085
+ left: 0;
1086
+ margin-left: -1px;
1087
+ }
1088
+
1089
+ .acf-gallery .toolbar .view-grid {
1090
+ width: 36px;
1091
+ height: 36px;
1092
+ background: url(../images/sprite.png) 11px -438px no-repeat;
1093
+ }
1094
+
1095
+ .acf-gallery .toolbar .view-list {
1096
+ width: 36px;
1097
+ height: 36px;
1098
+ background: url(../images/sprite.png) -40px -438px no-repeat;
1099
+ }
1100
+
1101
+ .acf-gallery .toolbar .view-grid-li,
1102
+ .acf-gallery .toolbar .view-list-li {
1103
+ position: absolute;
1104
+ left: 50%;
1105
+
1106
+ }
1107
+
1108
+ .acf-gallery .toolbar .view-grid-li {
1109
+ margin-left: -36px;
1110
+ }
1111
+
1112
+
1113
+ /*
1114
+ * Hover
1115
+ */
1116
+
1117
+ .acf-gallery .hover {
1118
+ position: absolute;
1119
+ top: -11px;
1120
+ right: -11px;
1121
+
1122
+ -webkit-transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
1123
+ -moz-transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
1124
+ -o-transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
1125
+ transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
1126
+
1127
+ visibility: hidden;
1128
+ opacity: 0;
1129
+ }
1130
+
1131
+ .acf-gallery .thumbnail:hover .hover {
1132
+ -webkit-transition-delay:0s;
1133
+ -moz-transition-delay:0s;
1134
+ -o-transition-delay:0s;
1135
+ transition-delay:0s;
1136
+
1137
+ visibility: visible;
1138
+ opacity: 1;
1139
+ }
1140
+
1141
+ .acf-gallery .hover ul {
1142
+ display: block;
1143
+ margin: 0;
1144
+ padding: 0;
1145
+ }
1146
+
1147
+ .acf-gallery .hover ul li {
1148
+ margin: 0 0 5px 0;
1149
+ }
1150
+
1151
+ .acf-gallery .hover a {
1152
+ background: url(../images/sprite.png) no-repeat scroll -54px -102px #fff;
1153
+ display: block;
1154
+ height: 22px;
1155
+ width: 22px;
1156
+ border-radius: 15px;
1157
+ border: #dfdfdf solid 1px;
1158
+ }
1159
+
1160
+ .acf-gallery .hover a:hover {
1161
+ background-position: -54px -152px;
1162
+ }
1163
+
1164
+ .acf-gallery .hover a.edit-image {
1165
+ background-position: -45px -345px;
1166
+ }
1167
+ .acf-gallery .hover a.edit-image:hover {
1168
+ background-position: -45px -395px;
1169
+ }
1170
+
1171
+ /*
1172
+ * List Data
1173
+ */
1174
+
1175
+ .acf-gallery .list-data {
1176
+ display: none;
1177
+ }
1178
+
1179
+ .acf-gallery.view-list .thumbnail {
1180
+ float: none;
1181
+ }
1182
+
1183
+ .acf-gallery.view-list .thumbnail .list-data {
1184
+ display: block;
1185
+ margin: 0 0 0 127px;
1186
+ }
1187
+
1188
+ .acf-gallery.view-list .thumbnail img {
1189
+ float: left;
1190
+ max-width: 122px;
1191
+ height: auto;
1192
+ }
1193
+
1194
+ .acf-gallery .list-data table {
1195
+ text-align: left;
1196
+ width: 100%;
1197
+ border-collapse: collapse;
1198
+ }
1199
+
1200
+ .acf-gallery .list-data table th,
1201
+ .acf-gallery .list-data table td {
1202
+ border: 1px solid #F1F1F1;
1203
+ padding: 6px;
1204
+ }
1205
+
1206
+ .acf-gallery .list-data table th {
1207
+ width: 110px;
1208
+ }
1209
+
1210
+ /*
1211
+ * Edit Image Message
1212
+ */
1213
+
1214
+ .acf-gallery .acf-message-wrapper {
1215
+ margin: 0;
1216
+ position: absolute;
1217
+ z-index: 1;
1218
+ width: 100%;
1219
+ background: #fff;
1220
+ }
1221
+
1222
+ .acf-gallery .acf-message-wrapper .message {
1223
+ margin: 5px !important;
1224
+ }
1225
+
1226
+ .acf-gallery.view-list .acf-message-wrapper {
1227
+ padding: 5px 5px 0;
1228
+ position: relative;
1229
+ width: auto;
1230
+ }
1231
+
1232
+ .acf-gallery.view-list .acf-message-wrapper .message {
1233
+ margin: 0px !important;
1234
+ }
images/sprite.png CHANGED
Binary file
js/input-actions.js CHANGED
@@ -7,8 +7,21 @@
7
  */
8
 
9
  var acf = {
 
 
10
  validation : false,
11
- validation_message : "Validation Failed. One or more fields below are required." // this is overriden by a script tag generated in admin_head for translation
 
 
 
 
 
 
 
 
 
 
 
12
  };
13
 
14
  (function($){
@@ -80,14 +93,11 @@ var acf = {
80
  // do validation
81
  do_validation();
82
 
83
- if(acf.valdation == false)
84
  {
85
- // reset validation for next time
86
- acf.valdation = true;
87
-
88
  // show message
89
  $(this).siblings('#message').remove();
90
- $(this).before('<div id="message" class="error"><p>' + acf.validation_message + '</p></div>');
91
 
92
 
93
  // hide ajax stuff on submit button
@@ -114,6 +124,8 @@ var acf = {
114
 
115
  function do_validation(){
116
 
 
 
117
  $('.field.required:visible, .form-field.required').each(function(){
118
 
119
  var validation = true;
@@ -174,11 +186,27 @@ var acf = {
174
  }
175
 
176
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
  // set validation
179
  if(!validation)
180
  {
181
- acf.valdation = false;
182
  $(this).closest('.field').addClass('error');
183
  }
184
 
@@ -296,7 +324,7 @@ var acf = {
296
  window.acf_div = div;
297
 
298
  // show the thickbox
299
- tb_show('Add File to field', acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
300
 
301
  return false;
302
  });
@@ -326,7 +354,7 @@ var acf = {
326
 
327
 
328
  // show edit attachment
329
- tb_show('Edit File', acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=file&TB_iframe=1');
330
 
331
 
332
  return false;
@@ -352,7 +380,7 @@ var acf = {
352
  window.acf_div = div;
353
 
354
  // show the thickbox
355
- tb_show('Add Image to field', acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
356
 
357
  return false;
358
  });
@@ -384,7 +412,7 @@ var acf = {
384
 
385
 
386
  // show edit attachment
387
- tb_show('Edit Image', acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=image&TB_iframe=1');
388
 
389
 
390
  return false;
@@ -454,7 +482,7 @@ var acf = {
454
  // max posts
455
  if(right.find('a:not(.hide)').length >= max)
456
  {
457
- alert('Maximum values reached ( ' + max + ' values )');
458
  return false;
459
  }
460
 
@@ -546,6 +574,7 @@ var acf = {
546
  $.fn.acf_deactivate_wysiwyg = function(){
547
 
548
  $(this).find('.acf_wysiwyg textarea').each(function(){
 
549
  tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
550
  });
551
 
@@ -584,7 +613,7 @@ var acf = {
584
 
585
  }
586
 
587
- //tinyMCE.init(tinyMCEPreInit.mceInit);
588
  tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
589
 
590
  });
@@ -606,13 +635,13 @@ var acf = {
606
 
607
  $(window).load(function(){
608
 
609
- $('#acf_settings-tmce').trigger('click');
610
-
611
  setTimeout(function(){
 
 
612
 
 
613
  $(document).trigger('acf/setup_fields', $('#poststuff'));
614
-
615
- }, 501);
616
 
617
 
618
  if(typeof(tinyMCE) != "object")
@@ -715,8 +744,9 @@ var acf = {
715
 
716
  $(postbox).find('.repeater').each(function(){
717
 
718
- var repeater = $(this);
719
- var row_limit = parseInt( repeater.attr('data-row_limit') );
 
720
 
721
 
722
  // move row-clone to be the first element (to avoid double border css bug)
@@ -730,13 +760,12 @@ var acf = {
730
  }
731
 
732
 
733
-
734
  // update classes based on row count
735
  repeater_check_rows( repeater );
736
 
737
 
738
  // sortable
739
- if(row_limit > 1){
740
  repeater_add_sortable( repeater );
741
  }
742
 
@@ -749,9 +778,9 @@ var acf = {
749
  function repeater_check_rows( repeater )
750
  {
751
  // vars
752
- var row_limit = parseInt( repeater.attr('data-row_limit') );
753
- var row_count = repeater.find('> table > tbody > tr.row').length;
754
-
755
 
756
  // empty?
757
  if( row_count == 0 )
@@ -765,7 +794,7 @@ var acf = {
765
 
766
 
767
  // row limit reached
768
- if( row_count >= row_limit )
769
  {
770
  repeater.addClass('disabled');
771
  }
@@ -779,28 +808,23 @@ var acf = {
779
  // add field
780
  function repeater_add_field( repeater, before )
781
  {
782
-
 
 
 
 
783
  // validate
784
- if( repeater.hasClass('disabled') )
785
  {
 
786
  return false;
787
  }
788
 
789
 
790
  // create and add the new field
791
- var new_field = repeater.find('> table > tbody > tr.row-clone').clone(false);
792
- new_field.attr('class', 'row');
793
-
794
-
795
- // update names
796
- var new_id = uniqid();
797
- new_field.find('[name]').each(function(){
798
-
799
- var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
800
- $(this).attr('name', name);
801
- $(this).attr('id', name);
802
-
803
- });
804
 
805
 
806
  // add row
@@ -837,17 +861,27 @@ var acf = {
837
 
838
  // add row - end
839
  $('.repeater .repeater-footer .add-row-end').live('click', function(){
 
840
  var repeater = $(this).closest('.repeater');
 
 
841
  repeater_add_field( repeater, false );
 
 
842
  return false;
843
  });
844
 
845
 
846
  // add row - before
847
  $('.repeater .add-row-before').live('click', function(){
848
- var repeater = $(this).closest('.repeater');
849
- var before = $(this).closest('tr');
 
 
 
850
  repeater_add_field( repeater, before );
 
 
851
  return false;
852
  });
853
 
@@ -855,10 +889,20 @@ var acf = {
855
  function repeater_remove_row( tr )
856
  {
857
  // vars
858
- var repeater = tr.closest('.repeater');
859
- var column_count = tr.children('tr.row').length;
860
- var row_height = tr.height();
861
-
 
 
 
 
 
 
 
 
 
 
862
 
863
  // animate out tr
864
  tr.addClass('acf-remove-item');
@@ -1004,27 +1048,23 @@ var acf = {
1004
 
1005
 
1006
  // create new field
1007
- var new_field = div.children('.clones').children('.layout[data-layout="' + layout + '"]').clone(false);
1008
-
1009
- // update names
1010
- var new_id = uniqid();
1011
- new_field.find('[name]').each(function(){
1012
-
1013
- var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
1014
- $(this).attr('name', name);
1015
- $(this).attr('id', name);
1016
 
1017
- });
1018
 
1019
  // hide no values message
1020
  div.children('.no_value_message').hide();
1021
 
 
1022
  // add row
1023
  div.children('.values').append(new_field);
1024
 
 
1025
  // activate wysiwyg
1026
  $(document).trigger('acf/setup_fields',new_field);
1027
 
 
1028
  // validation
1029
  div.closest('.field').removeClass('error');
1030
 
@@ -1087,6 +1127,14 @@ var acf = {
1087
  });
1088
 
1089
 
 
 
 
 
 
 
 
 
1090
  acf.add_message = function( message, div ){
1091
 
1092
  var message = $('<div class="acf-message-wrapper"><div class="message updated"><p>' + message + '</p></div></div>');
@@ -1106,4 +1154,170 @@ var acf = {
1106
  };
1107
 
1108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1109
  })(jQuery);
7
  */
8
 
9
  var acf = {
10
+ admin_url : '',
11
+ post_id : 0,
12
  validation : false,
13
+ text : {
14
+ 'validation_error' : "Validation Failed. One or more fields below are required.",
15
+ 'file_tb_title_add' : "Add File to Field",
16
+ 'file_tb_title_edit' : "Edit File",
17
+ 'image_tb_title_add' : "Add Image to Field",
18
+ 'image_tb_title_edit' : "Edit Image",
19
+ 'relationship_max_alert' : "Maximum values reached ( {max} values )",
20
+ 'gallery_tb_title_add' : "Add Image to Gallery",
21
+ 'gallery_tb_title_edit' : "Edit Image",
22
+ 'repeater_min_alert' : "Minimum rows reached ( {min} rows )",
23
+ 'repeater_max_alert' : "Maximum rows reached ( {max} rows )"
24
+ }
25
  };
26
 
27
  (function($){
93
  // do validation
94
  do_validation();
95
 
96
+ if(acf.validation == false)
97
  {
 
 
 
98
  // show message
99
  $(this).siblings('#message').remove();
100
+ $(this).before('<div id="message" class="error"><p>' + acf.text.validation_error + '</p></div>');
101
 
102
 
103
  // hide ajax stuff on submit button
124
 
125
  function do_validation(){
126
 
127
+ acf.validation = true;
128
+
129
  $('.field.required:visible, .form-field.required').each(function(){
130
 
131
  var validation = true;
186
  }
187
 
188
  }
189
+
190
+
191
+ // gallery
192
+ if($(this).find('.acf-gallery').exists())
193
+ {
194
+ if($(this).find('.acf-gallery .thumbnail').exists())
195
+ {
196
+ validation = true;
197
+ }
198
+ else
199
+ {
200
+ validation = false;
201
+ }
202
+
203
+ }
204
+
205
 
206
  // set validation
207
  if(!validation)
208
  {
209
+ acf.validation = false;
210
  $(this).closest('.field').addClass('error');
211
  }
212
 
324
  window.acf_div = div;
325
 
326
  // show the thickbox
327
+ tb_show( acf.text.file_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
328
 
329
  return false;
330
  });
354
 
355
 
356
  // show edit attachment
357
+ tb_show( acf.text.file_tb_title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=file&TB_iframe=1');
358
 
359
 
360
  return false;
380
  window.acf_div = div;
381
 
382
  // show the thickbox
383
+ tb_show( acf.text.image_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
384
 
385
  return false;
386
  });
412
 
413
 
414
  // show edit attachment
415
+ tb_show( acf.text.image_tb_title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=image&TB_iframe=1');
416
 
417
 
418
  return false;
482
  // max posts
483
  if(right.find('a:not(.hide)').length >= max)
484
  {
485
+ alert( acf.text.relationship_max_alert.replace('{max}', max) );
486
  return false;
487
  }
488
 
574
  $.fn.acf_deactivate_wysiwyg = function(){
575
 
576
  $(this).find('.acf_wysiwyg textarea').each(function(){
577
+ wpActiveEditor = null;
578
  tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
579
  });
580
 
613
 
614
  }
615
 
616
+ wpActiveEditor = null;
617
  tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
618
 
619
  });
635
 
636
  $(window).load(function(){
637
 
 
 
638
  setTimeout(function(){
639
+ $('#acf_settings-tmce').trigger('click');
640
+ }, 1);
641
 
642
+ setTimeout(function(){
643
  $(document).trigger('acf/setup_fields', $('#poststuff'));
644
+ }, 10);
 
645
 
646
 
647
  if(typeof(tinyMCE) != "object")
744
 
745
  $(postbox).find('.repeater').each(function(){
746
 
747
+ var repeater = $(this),
748
+ min_rows = parseInt( repeater.attr('data-min_rows') ),
749
+ max_rows = parseInt( repeater.attr('data-max_rows') );
750
 
751
 
752
  // move row-clone to be the first element (to avoid double border css bug)
760
  }
761
 
762
 
 
763
  // update classes based on row count
764
  repeater_check_rows( repeater );
765
 
766
 
767
  // sortable
768
+ if( max_rows > 1 ){
769
  repeater_add_sortable( repeater );
770
  }
771
 
778
  function repeater_check_rows( repeater )
779
  {
780
  // vars
781
+ var max_rows = parseInt( repeater.attr('data-max_rows') ),
782
+ row_count = repeater.find('> table > tbody > tr.row').length;
783
+
784
 
785
  // empty?
786
  if( row_count == 0 )
794
 
795
 
796
  // row limit reached
797
+ if( row_count >= max_rows )
798
  {
799
  repeater.addClass('disabled');
800
  }
808
  // add field
809
  function repeater_add_field( repeater, before )
810
  {
811
+ // vars
812
+ var max_rows = parseInt( repeater.attr('data-max_rows') ),
813
+ row_count = repeater.find('> table > tbody > tr.row').length;
814
+
815
+
816
  // validate
817
+ if( row_count >= max_rows )
818
  {
819
+ alert( acf.text.repeater_max_alert.replace('{max}', max_rows) );
820
  return false;
821
  }
822
 
823
 
824
  // create and add the new field
825
+ var new_id = uniqid(),
826
+ new_field_html = repeater.find('> table > tbody > tr.row-clone').html().replace(/(="[\w-\[\]]*?)(\[999\])/g, '$1[' + new_id + ']'),
827
+ new_field = $('<tr class="row"></tr>').append( new_field_html );
 
 
 
 
 
 
 
 
 
 
828
 
829
 
830
  // add row
861
 
862
  // add row - end
863
  $('.repeater .repeater-footer .add-row-end').live('click', function(){
864
+
865
  var repeater = $(this).closest('.repeater');
866
+
867
+
868
  repeater_add_field( repeater, false );
869
+
870
+
871
  return false;
872
  });
873
 
874
 
875
  // add row - before
876
  $('.repeater .add-row-before').live('click', function(){
877
+
878
+ var repeater = $(this).closest('.repeater'),
879
+ before = $(this).closest('tr');
880
+
881
+
882
  repeater_add_field( repeater, before );
883
+
884
+
885
  return false;
886
  });
887
 
889
  function repeater_remove_row( tr )
890
  {
891
  // vars
892
+ var repeater = tr.closest('.repeater'),
893
+ min_rows = parseInt( repeater.attr('data-min_rows') ),
894
+ row_count = repeater.find('> table > tbody > tr.row').length,
895
+ column_count = tr.children('tr.row').length,
896
+ row_height = tr.height();
897
+
898
+
899
+ // validate
900
+ if( row_count <= min_rows )
901
+ {
902
+ alert( acf.text.repeater_min_alert.replace('{min}', row_count) );
903
+ return false;
904
+ }
905
+
906
 
907
  // animate out tr
908
  tr.addClass('acf-remove-item');
1048
 
1049
 
1050
  // create new field
1051
+ var new_id = uniqid(),
1052
+ new_field_html = div.find('> .clones > .layout[data-layout="' + layout + '"]').html().replace(/(="[\w-\[\]]*?)(\[999\])/g, '$1[' + new_id + ']'),
1053
+ new_field = $('<div class="layout" data-layout="' + layout + '"></div>').append( new_field_html );
 
 
 
 
 
 
1054
 
 
1055
 
1056
  // hide no values message
1057
  div.children('.no_value_message').hide();
1058
 
1059
+
1060
  // add row
1061
  div.children('.values').append(new_field);
1062
 
1063
+
1064
  // activate wysiwyg
1065
  $(document).trigger('acf/setup_fields',new_field);
1066
 
1067
+
1068
  // validation
1069
  div.closest('.field').removeClass('error');
1070
 
1127
  });
1128
 
1129
 
1130
+ /*
1131
+ * acf.add_message
1132
+ *
1133
+ * @description:
1134
+ * @since: 3.2.7
1135
+ * @created: 10/07/2012
1136
+ */
1137
+
1138
  acf.add_message = function( message, div ){
1139
 
1140
  var message = $('<div class="acf-message-wrapper"><div class="message updated"><p>' + message + '</p></div></div>');
1154
  };
1155
 
1156
 
1157
+ /*
1158
+ * Field: Gallery
1159
+ *
1160
+ * @description:
1161
+ * @since: 3.2.7
1162
+ * @created: 10/07/2012
1163
+ */
1164
+
1165
+ acf.update_gallery_count = function( div )
1166
+ {
1167
+ // vars
1168
+ var count = div.find('.thumbnails .thumbnail').length,
1169
+ max_count = ( count > 2 ) ? 2 : count,
1170
+ span = div.find('.toolbar .count');
1171
+
1172
+
1173
+ span.html( span.attr('data-' + max_count).replace('{count}', count) );
1174
+
1175
+ }
1176
+
1177
+
1178
+ // view: Grid
1179
+ $('.acf-gallery .toolbar .view-grid').live('click', function(){
1180
+
1181
+ // vars
1182
+ var gallery = $(this).closest('.acf-gallery');
1183
+
1184
+
1185
+ // active class
1186
+ $(this).parent().addClass('active').siblings('.view-list-li').removeClass('active');
1187
+
1188
+
1189
+ // gallery class
1190
+ gallery.removeClass('view-list');
1191
+
1192
+
1193
+ return false;
1194
+
1195
+ });
1196
+
1197
+
1198
+ // view: Grid
1199
+ $('.acf-gallery .toolbar .view-list').live('click', function(){
1200
+
1201
+ // vars
1202
+ var gallery = $(this).closest('.acf-gallery');
1203
+
1204
+
1205
+ // active class
1206
+ $(this).parent().addClass('active').siblings('.view-grid-li').removeClass('active');
1207
+
1208
+
1209
+ // gallery class
1210
+ gallery.addClass('view-list');
1211
+
1212
+
1213
+ return false;
1214
+
1215
+ });
1216
+
1217
+
1218
+ // remove image
1219
+ $('.acf-gallery .thumbnail .remove-image').live('click', function(){
1220
+
1221
+ // vars
1222
+ var thumbnail = $(this).closest('.thumbnail'),
1223
+ gallery = thumbnail.closest('.acf-gallery');
1224
+
1225
+
1226
+ thumbnail.animate({
1227
+ opacity : 0
1228
+ }, 250, function(){
1229
+
1230
+ thumbnail.remove();
1231
+
1232
+ acf.update_gallery_count( gallery );
1233
+
1234
+ });
1235
+
1236
+ return false;
1237
+
1238
+ });
1239
+
1240
+
1241
+ // remove image
1242
+ $('.acf-gallery .thumbnail .edit-image').live('click', function(){
1243
+
1244
+ // vars
1245
+ var div = $(this).closest('.thumbnail'),
1246
+ id = div.attr('data-id');
1247
+
1248
+
1249
+ // set global var
1250
+ window.acf_edit_attachment = div;
1251
+
1252
+
1253
+ // show edit attachment
1254
+ tb_show( acf.text.gallery_tb_title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=gallery&TB_iframe=1');
1255
+
1256
+
1257
+ return false;
1258
+
1259
+ });
1260
+
1261
+
1262
+ $(document).live('acf/setup_fields', function(e, postbox){
1263
+
1264
+ $(postbox).find('.acf-gallery').each(function(i){
1265
+
1266
+ // vars
1267
+ var div = $(this),
1268
+ thumbnails = div.find('.thumbnails'),
1269
+ toolbar = div.find('.toolbar'),
1270
+ preview_size = div.attr('data-preview_size');
1271
+
1272
+
1273
+ // update count
1274
+ acf.update_gallery_count( div );
1275
+
1276
+
1277
+ // add new
1278
+ toolbar.find('.add-image').unbind('click').click( function(){
1279
+
1280
+
1281
+ // set global var
1282
+ window.acf_div = div;
1283
+
1284
+
1285
+ // show the thickbox
1286
+ tb_show( acf.text.gallery_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=image&acf_type=gallery&acf_preview_size=' + preview_size + 'TB_iframe=1');
1287
+
1288
+
1289
+ return false;
1290
+
1291
+ });
1292
+
1293
+
1294
+ // sortable
1295
+ thumbnails.find('> .inner').unbind('sortable').sortable({
1296
+ items : '> .thumbnail',
1297
+ /* handle: '> td.order', */
1298
+ forceHelperSize: true,
1299
+ forcePlaceholderSize: true,
1300
+ scroll: true,
1301
+ start: function (event, ui) {
1302
+
1303
+ // alter width / height to allow for 2px border
1304
+ ui.placeholder.width( ui.placeholder.width() - 4 );
1305
+ ui.placeholder.height( ui.placeholder.height() - 4 );
1306
+ }
1307
+ });
1308
+
1309
+
1310
+ return false;
1311
+
1312
+ });
1313
+
1314
+ });
1315
+
1316
+ setInterval(function(){
1317
+
1318
+ //console.log( tinyMCE.activeEditor );
1319
+
1320
+ }, 2000)
1321
+
1322
+
1323
  })(jQuery);
readme.txt CHANGED
@@ -85,6 +85,13 @@ http://www.advancedcustomfields.com/support/
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
88
  = 3.2.7 =
89
  * [Fixed] Rename controller classes - http://www.advancedcustomfields.com/support/discussion/2363/fatal-error-after-update-to-3.2.6
90
  * [Added] Add edit button to image / file fields
85
 
86
  == Changelog ==
87
 
88
+ = 3.2.8 =
89
+ * [Added] Repeater - Add option for min rows + max rows - http://www.advancedcustomfields.com/support/discussion/2111/repeater-empty-conditional-statements#Item_4
90
+ * [Fixed] Test / Fix Chrome Double WYSIWYG. Again...
91
+ * [Added] Add "future" to post status options - http://advancedcustomfields.com/support/discussion/1975/changed-line-81-and-94-of-corefieldspost_object-to-show-future-entries
92
+ * [Added] Make image sizes strings "Pretty" for preview size options
93
+ * [Fixed] Test / Fix WYSIWYG insert image inside a repeater bug - http://www.advancedcustomfields.com/support/discussion/2404/problem-with-repeater-wysiwyg-fields-and-images
94
+
95
  = 3.2.7 =
96
  * [Fixed] Rename controller classes - http://www.advancedcustomfields.com/support/discussion/2363/fatal-error-after-update-to-3.2.6
97
  * [Added] Add edit button to image / file fields