Advanced Custom Fields - Version 3.0.1

Version Description

  • Bug Fix - repeater + wysiwyg delete / add duplicate id error
  • Bug fix - repeater + file - add file not working
  • Bug Fix - image / file no longer need the post type to support "editor"
  • WYSIWYG - fixed broken upload images
  • misc updates to accommodate the soon to be released "Flexible Field"
Download this release

Release Info

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

Code changes from version 3.0.0 to 3.0.1

acf.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
5
  Description: Customise your edit pages with an assortment of field types: Wysiwyg, Repeater, text, textarea, image, file, select, checkbox post type, page link and more! Hide unwanted metaboxes and assign to any edit page!
6
- Version: 3.0.0
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -45,7 +45,7 @@ class Acf
45
  $this->dir = plugins_url('',__FILE__);
46
  $this->siteurl = get_bloginfo('url');
47
  $this->wpadminurl = admin_url();
48
- $this->version = '3.0.0';
49
  $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
50
 
51
 
@@ -67,10 +67,14 @@ class Acf
67
  add_action('admin_print_scripts', array($this, 'admin_print_scripts'));
68
  add_action('admin_print_styles', array($this, 'admin_print_styles'));
69
  add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
 
70
  return true;
71
  }
72
 
73
 
 
 
 
74
  /*--------------------------------------------------------------------------------------
75
  *
76
  * setup_fields
@@ -303,6 +307,12 @@ class Acf
303
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/global.css" />';
304
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/fields.css" />';
305
 
 
 
 
 
 
 
306
  add_meta_box('acf_fields', 'Fields', array($this, 'meta_box_fields'), 'acf', 'normal', 'high');
307
  add_meta_box('acf_location', 'Location </span><span class="description">- Add Fields to Edit Screens', array($this, 'meta_box_location'), 'acf', 'normal', 'high');
308
  add_meta_box('acf_options', 'Options</span><span class="description">- Customise the edit page', array($this, 'meta_box_options'), 'acf', 'normal', 'high');
@@ -393,6 +403,7 @@ class Acf
393
  // input meta boxes
394
  if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')) && $GLOBALS['post_type'] != 'acf')
395
  {
 
396
  ?>
397
  <script type="text/javascript">
398
  (function($){
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
5
  Description: Customise your edit pages with an assortment of field types: Wysiwyg, Repeater, text, textarea, image, file, select, checkbox post type, page link and more! Hide unwanted metaboxes and assign to any edit page!
6
+ Version: 3.0.1
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
45
  $this->dir = plugins_url('',__FILE__);
46
  $this->siteurl = get_bloginfo('url');
47
  $this->wpadminurl = admin_url();
48
+ $this->version = '3.0.1';
49
  $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
50
 
51
 
67
  add_action('admin_print_scripts', array($this, 'admin_print_scripts'));
68
  add_action('admin_print_styles', array($this, 'admin_print_styles'));
69
  add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
70
+
71
  return true;
72
  }
73
 
74
 
75
+
76
+
77
+
78
  /*--------------------------------------------------------------------------------------
79
  *
80
  * setup_fields
307
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/global.css" />';
308
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/fields.css" />';
309
 
310
+ // fields admin_head
311
+ foreach($this->fields as $field)
312
+ {
313
+ $this->fields[$field->name]->admin_head_field();
314
+ }
315
+
316
  add_meta_box('acf_fields', 'Fields', array($this, 'meta_box_fields'), 'acf', 'normal', 'high');
317
  add_meta_box('acf_location', 'Location </span><span class="description">- Add Fields to Edit Screens', array($this, 'meta_box_location'), 'acf', 'normal', 'high');
318
  add_meta_box('acf_options', 'Options</span><span class="description">- Customise the edit page', array($this, 'meta_box_options'), 'acf', 'normal', 'high');
403
  // input meta boxes
404
  if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')) && $GLOBALS['post_type'] != 'acf')
405
  {
406
+ wp_preload_dialogs( array( 'plugins' => 'safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage,wpgallery,tabfocus' ) );
407
  ?>
408
  <script type="text/javascript">
409
  (function($){
core/admin/meta_box_fields.php CHANGED
@@ -59,7 +59,7 @@ foreach($this->fields as $field)
59
  </div>
60
  </td>
61
  <td class="field_name"><?php echo $field['name']; ?></td>
62
- <td class="field_type"><?php echo $field['type']; ?></td>
63
  </tr>
64
  </table>
65
  </div>
59
  </div>
60
  </td>
61
  <td class="field_name"><?php echo $field['name']; ?></td>
62
+ <td class="field_type"><?php echo $fields_names[$field['type']]; ?></td>
63
  </tr>
64
  </table>
65
  </div>
core/api.php CHANGED
@@ -114,7 +114,14 @@ function get_field($field_name, $post_id = false)
114
 
115
  function the_field($field_name, $post_id = false)
116
  {
117
- echo get_field($field_name, $post_id);
 
 
 
 
 
 
 
118
  }
119
 
120
 
@@ -155,6 +162,11 @@ function the_repeater_field($field_name, $post_id = false)
155
 
156
  }
157
 
 
 
 
 
 
158
 
159
  /*--------------------------------------------------------------------------------------
160
  *
@@ -246,4 +258,31 @@ function acf_register_field($array)
246
  }
247
  add_filter('acf_register_field', 'acf_register_field');
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  ?>
114
 
115
  function the_field($field_name, $post_id = false)
116
  {
117
+ $value = get_field($field_name, $post_id);
118
+
119
+ if(is_array($value))
120
+ {
121
+ $value = @implode(', ',$value);
122
+ }
123
+
124
+ echo $value;
125
  }
126
 
127
 
162
 
163
  }
164
 
165
+ function the_flexible_field($field_name, $post_id = false)
166
+ {
167
+ return the_repeater_field($field_name, $post_id);
168
+ }
169
+
170
 
171
  /*--------------------------------------------------------------------------------------
172
  *
258
  }
259
  add_filter('acf_register_field', 'acf_register_field');
260
 
261
+
262
+
263
+ /*--------------------------------------------------------------------------------------
264
+ *
265
+ * get_sub_field
266
+ *
267
+ * @author Elliot Condon
268
+ * @since 1.0.3
269
+ *
270
+ *-------------------------------------------------------------------------------------*/
271
+
272
+ function get_row_layout()
273
+ {
274
+
275
+ // vars
276
+ $field = $GLOBALS['acf_field'];
277
+ $i = $GLOBALS['acf_count'];
278
+
279
+ // no value
280
+ if(!$field) return false;
281
+
282
+ if(!isset($field[$i]['acf_fc_layout'])) return false;
283
+
284
+ return $field[$i]['acf_fc_layout'];
285
+ }
286
+
287
+
288
  ?>
core/fields/acf_field.php CHANGED
@@ -79,6 +79,22 @@ class acf_Field
79
  }
80
 
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  /*--------------------------------------------------------------------------------------
83
  *
84
  * admin_print_scripts / admin_print_styles
79
  }
80
 
81
 
82
+ /*--------------------------------------------------------------------------------------
83
+ *
84
+ * admin_head_field
85
+ * - called on the acf edit page - used for adding script / styles to field options
86
+ *
87
+ * @author Elliot Condon
88
+ * @since 2.2.0
89
+ *
90
+ *-------------------------------------------------------------------------------------*/
91
+
92
+ function admin_head_field()
93
+ {
94
+
95
+ }
96
+
97
+
98
  /*--------------------------------------------------------------------------------------
99
  *
100
  * admin_print_scripts / admin_print_styles
core/fields/date_picker/style.date_picker.css CHANGED
File without changes
core/fields/file.php CHANGED
@@ -21,9 +21,26 @@ class acf_File extends acf_Field
21
 
22
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
23
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
 
24
  }
25
 
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  /*--------------------------------------------------------------------------------------
28
  *
29
  * admin_print_scripts / admin_print_styles
@@ -68,40 +85,34 @@ class acf_File extends acf_Field
68
  <script type="text/javascript">
69
 
70
  (function($){
71
-
72
- $(document).ready(function(){
73
 
 
 
74
  var post_id = $('input#post_ID').val();
75
 
76
- $('#poststuff .acf_file_uploader').each(function(){
77
-
78
- //console.log('file setup');
79
- var div = $(this);
80
-
81
- div.find('p.no_file input.button').click(function(){
82
-
83
- // set global var
84
- window.acf_div = div;
85
-
86
- // show the thickbox
87
- tb_show('Add File to field', 'media-upload.php?post_id='+post_id+'&type=file&acf_type=file&TB_iframe=1');
88
-
89
- return false;
90
- });
91
-
92
-
93
- div.find('p.file input.button').unbind('click').click(function()
94
- {
95
- div.find('input.value').val('');
96
- div.removeClass('active');
97
 
98
- return false;
99
- });
 
 
 
100
 
101
- });
102
 
 
 
 
 
 
 
 
103
 
104
  });
 
105
 
106
  })(jQuery);
107
  </script>
21
 
22
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
23
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
24
+ add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
25
  }
26
 
27
 
28
+ /*--------------------------------------------------------------------------------------
29
+ *
30
+ * admin_print_scripts / admin_print_styles
31
+ *
32
+ * @author Elliot Condon
33
+ * @since 3.0.1
34
+ *
35
+ *-------------------------------------------------------------------------------------*/
36
+
37
+ function allow_img_insertion($vars)
38
+ {
39
+ $vars['send'] = true;
40
+ return($vars);
41
+ }
42
+
43
+
44
  /*--------------------------------------------------------------------------------------
45
  *
46
  * admin_print_scripts / admin_print_styles
85
  <script type="text/javascript">
86
 
87
  (function($){
88
+
89
+ $('#poststuff .acf_file_uploader .no_file .button').live('click', function(){
90
 
91
+ // vars
92
+ var div = $(this).closest('.acf_file_uploader');
93
  var post_id = $('input#post_ID').val();
94
 
95
+ // set global var
96
+ window.acf_div = div;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ // show the thickbox
99
+ tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=file&acf_type=file&TB_iframe=1');
100
+
101
+ return false;
102
+ });
103
 
104
+ $('#poststuff .acf_file_uploader .file .button').live('click', function(){
105
 
106
+ // vars
107
+ var div = $(this).closest('.acf_file_uploader');
108
+
109
+ div.find('input.value').val('');
110
+ div.removeClass('active');
111
+
112
+ return false;
113
 
114
  });
115
+
116
 
117
  })(jQuery);
118
  </script>
core/fields/image.php CHANGED
@@ -22,9 +22,26 @@ class acf_Image extends acf_Field
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
 
25
  }
26
 
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /*--------------------------------------------------------------------------------------
29
  *
30
  * admin_print_scripts / admin_print_styles
@@ -69,39 +86,35 @@ class acf_Image extends acf_Field
69
  <script type="text/javascript">
70
 
71
  (function($){
72
-
73
- $(document).ready(function(){
74
 
75
- $('#poststuff .acf_image_uploader .button').live('click', function(){
76
-
77
- // vars
78
- var div = $(this).closest('.acf_image_uploader');
79
- var post_id = $('input#post_ID').val();
80
- var preview_size = div.attr('data-preview_size');
81
-
82
- // set global var
83
- window.acf_div = div;
84
-
85
- // show the thickbox
86
- tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
87
 
88
- return false;
89
- });
90
-
91
- $('#poststuff .acf_image_uploader .remove_image').live('click', function(){
92
-
93
- // vars
94
- var div = $(this).closest('.acf_image_uploader');
95
 
96
- div.find('input.value').val('');
97
- div.removeClass('active');
98
-
99
- return false;
100
-
101
- });
 
 
 
 
 
 
 
 
 
102
 
103
  });
104
-
105
  })(jQuery);
106
  </script>
107
  <?php
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
25
+ add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
26
  }
27
 
28
 
29
+ /*--------------------------------------------------------------------------------------
30
+ *
31
+ * admin_print_scripts / admin_print_styles
32
+ *
33
+ * @author Elliot Condon
34
+ * @since 3.0.1
35
+ *
36
+ *-------------------------------------------------------------------------------------*/
37
+
38
+ function allow_img_insertion($vars)
39
+ {
40
+ $vars['send'] = true;
41
+ return($vars);
42
+ }
43
+
44
+
45
  /*--------------------------------------------------------------------------------------
46
  *
47
  * admin_print_scripts / admin_print_styles
86
  <script type="text/javascript">
87
 
88
  (function($){
89
+
90
+ $('#poststuff .acf_image_uploader .button').live('click', function(){
91
 
92
+ // vars
93
+ var div = $(this).closest('.acf_image_uploader');
94
+ var post_id = $('input#post_ID').val();
95
+ var preview_size = div.attr('data-preview_size');
 
 
 
 
 
 
 
 
96
 
97
+ // set global var
98
+ window.acf_div = div;
 
 
 
 
 
99
 
100
+ // show the thickbox
101
+ tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
102
+
103
+ return false;
104
+ });
105
+
106
+ $('#poststuff .acf_image_uploader .remove_image').live('click', function(){
107
+
108
+ // vars
109
+ var div = $(this).closest('.acf_image_uploader');
110
+
111
+ div.find('input.value').val('');
112
+ div.removeClass('active');
113
+
114
+ return false;
115
 
116
  });
117
+
118
  })(jQuery);
119
  </script>
120
  <?php
core/fields/repeater.php CHANGED
@@ -63,15 +63,21 @@ class acf_Repeater extends acf_Field
63
  (function($){
64
 
65
 
 
 
 
 
 
 
66
  /*----------------------------------------------------------------------
67
  *
68
  * Update Order Numbers
69
  *
70
  *---------------------------------------------------------------------*/
71
 
72
- $.fn.update_order_numbers = function(){
73
-
74
- $(this).children('table').children('tbody').children('tr').each(function(i){
75
  $(this).children('td.order').html(i+1);
76
  });
77
 
@@ -80,12 +86,10 @@ class acf_Repeater extends acf_Field
80
 
81
  /*----------------------------------------------------------------------
82
  *
83
- * Sortable
84
  *
85
  *---------------------------------------------------------------------*/
86
- $.fn.make_sortable = function(){
87
-
88
- var r = $(this);
89
 
90
  var fixHelper = function(e, ui) {
91
  ui.children().each(function() {
@@ -94,25 +98,12 @@ class acf_Repeater extends acf_Field
94
  return ui;
95
  };
96
 
97
- r.children('table').children('tbody').unbind('sortable').sortable({
98
  update: function(event, ui){
99
- r.update_order_numbers();
100
- //r.setup_wysiwyg();
101
- //r.setup_relationship();
102
- //r.setup_datepicker();
103
- //r.setup_image();
104
- //r.setup_file();
105
  },
106
  handle: 'td.order',
107
  helper: fixHelper,
108
- start: function(event, ui)
109
- {
110
-
111
- },
112
- stop: function(event, ui)
113
- {
114
- //ui.item.setup_wysiwyg();
115
- }
116
  });
117
  };
118
 
@@ -121,115 +112,95 @@ class acf_Repeater extends acf_Field
121
 
122
  $('#poststuff .repeater').each(function(){
123
 
124
- var r = $(this);
125
- var row_limit = parseInt(r.attr('data-row_limit'));
126
- var row_count = r.children('table').children('tbody').children('tr.row').length;
127
 
128
  // has limit been reached?
129
- if(row_count >= row_limit) r.find('#add_field').attr('disabled','true');
130
 
131
  // sortable
132
  if(row_limit > 1){
133
- r.make_sortable();
134
  }
135
 
136
  });
137
-
138
-
139
- // add field
140
- $('#poststuff .repeater #add_field').live('click', function(){
141
-
142
- var r = $(this).closest('.repeater');
143
- var row_limit = parseInt(r.attr('data-row_limit'));
144
- var row_count = r.children('table').children('tbody').children('tr.row').length;
145
-
146
- // row limit
147
- if(row_count >= row_limit)
148
- {
149
- // reached row limit!
150
- r.find('#add_field').attr('disabled','true');
151
- return false;
152
- }
153
-
154
- // create and add the new field
155
- var new_field = r.children('table').children('tbody').children('tr.row_clone').clone(false);
156
- new_field.attr('class', 'row');
157
- r.children('table').children('tbody').append(new_field);
158
-
159
- // update names
160
- new_field.find('[name]').each(function(){
161
-
162
- var name = $(this).attr('name').replace('[999]','['+row_count+']');
163
- $(this).attr('name', name);
164
- $(this).attr('id', name);
165
-
166
- });
167
-
168
- // reset values
169
- //if(!shift_is_down)
170
- //{
171
- //new_field.reset_values();
172
- //}
173
-
174
- // setup sub fields
175
- //new_field.setup_wysiwyg();
176
- //new_field.setup_relationship();
177
- //new_field.setup_datepicker();
178
- //new_field.setup_image();
179
- //new_field.setup_file();
180
-
181
- r.update_order_numbers();
182
-
183
- // there is now 1 more row
184
- row_count ++;
185
-
186
- // disable the add field button if row limit is reached
187
- if((row_count+1) >= row_limit)
188
- {
189
- r.find('#add_field').attr('disabled','true');
190
- }
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  });
195
 
 
 
196
 
197
- // remove field
198
- $('#poststuff .repeater a.remove_field').die('click');
199
- $('#poststuff .repeater a.remove_field').live('click', function(){
200
-
201
- var r = $(this).closest('.repeater');
202
- var tr = $(this).closest('tr');
203
-
204
- tr.find('td').animate({'opacity':'0', 'height' : '0px'}, 300,function(){
205
- tr.remove();
206
- r.update_order_numbers();
207
- });
208
-
209
- r.find('#add_field').removeAttr('disabled');
210
-
211
- return false;
212
-
 
 
 
 
 
 
 
 
 
 
 
 
213
  });
214
-
215
-
216
- // Update Order Numbers
217
- $.fn.update_order_numbers = function(){
218
-
219
- $(this).children('table').children('tbody').children('tr.row').each(function(i){
220
- $(this).children('td.order').html(i+1);
221
- });
222
 
223
- };
 
 
 
224
  });
225
 
226
  })(jQuery);
227
  </script>
228
- <style type="text/css">
229
- .repeater tr.row_clone {
230
- display: none;
231
- }
232
- </style>
233
  <?php
234
  }
235
 
63
  (function($){
64
 
65
 
66
+ function uniqid()
67
+ {
68
+ var newDate = new Date;
69
+ return newDate.getTime();
70
+ }
71
+
72
  /*----------------------------------------------------------------------
73
  *
74
  * Update Order Numbers
75
  *
76
  *---------------------------------------------------------------------*/
77
 
78
+ function update_order_numbers(div)
79
+ {
80
+ div.children('table').children('tbody').children('tr.row').each(function(i){
81
  $(this).children('td.order').html(i+1);
82
  });
83
 
86
 
87
  /*----------------------------------------------------------------------
88
  *
89
+ * Make Sortable
90
  *
91
  *---------------------------------------------------------------------*/
92
+ function make_sortable(div){
 
 
93
 
94
  var fixHelper = function(e, ui) {
95
  ui.children().each(function() {
98
  return ui;
99
  };
100
 
101
+ div.children('table').children('tbody').unbind('sortable').sortable({
102
  update: function(event, ui){
103
+ update_order_numbers(div);
 
 
 
 
 
104
  },
105
  handle: 'td.order',
106
  helper: fixHelper,
 
 
 
 
 
 
 
 
107
  });
108
  };
109
 
112
 
113
  $('#poststuff .repeater').each(function(){
114
 
115
+ var div = $(this);
116
+ var row_limit = parseInt(div.attr('data-row_limit'));
117
+ var row_count = div.children('table').children('tbody').children('tr.row').length;
118
 
119
  // has limit been reached?
120
+ if(row_count >= row_limit) div.find('#add_field').attr('disabled','true');
121
 
122
  // sortable
123
  if(row_limit > 1){
124
+ make_sortable(div)
125
  }
126
 
127
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
+ });
130
+
131
+ // add field
132
+ $('#poststuff .repeater #add_field').live('click', function(){
133
+
134
+ var div = $(this).closest('.repeater');
135
+ var row_limit = parseInt(div.attr('data-row_limit'));
136
+ var row_count = div.children('table').children('tbody').children('tr.row').length;
137
+
138
+ // row limit
139
+ if(row_count >= row_limit)
140
+ {
141
+ // reached row limit!
142
+ div.find('#add_field').attr('disabled','true');
143
  return false;
144
+ }
145
+
146
+ // deactivate any wysiwygs
147
+ div.children('table').children('tbody').children('tr.row_clone').acf_deactivate_wysiwyg();
148
+
149
+ // create and add the new field
150
+ var new_field = div.children('table').children('tbody').children('tr.row_clone').clone(false);
151
+ new_field.attr('class', 'row');
152
+
153
+ // update names
154
+ var new_id = uniqid();
155
+ new_field.find('[name]').each(function(){
156
+
157
+ var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
158
+ $(this).attr('name', name);
159
+ $(this).attr('id', name);
160
 
161
  });
162
 
163
+ // add row
164
+ div.children('table').children('tbody').append(new_field);
165
 
166
+ // activate wysiwyg
167
+ new_field.acf_activate_wysiwyg();
168
+
169
+ update_order_numbers(div);
170
+
171
+ // there is now 1 more row
172
+ row_count ++;
173
+
174
+ // disable the add field button if row limit is reached
175
+ if((row_count+1) >= row_limit)
176
+ {
177
+ div.find('#add_field').attr('disabled','true');
178
+ }
179
+
180
+ return false;
181
+
182
+ });
183
+
184
+
185
+ // remove field
186
+ $('#poststuff .repeater a.remove_field').live('click', function(){
187
+
188
+ var div = $(this).closest('.repeater');
189
+ var tr = $(this).closest('tr');
190
+
191
+ tr.animate({'left' : '50px', 'opacity' : 0}, 250,function(){
192
+ tr.remove();
193
+ update_order_numbers(div);
194
  });
 
 
 
 
 
 
 
 
195
 
196
+ div.find('#add_field').removeAttr('disabled');
197
+
198
+ return false;
199
+
200
  });
201
 
202
  })(jQuery);
203
  </script>
 
 
 
 
 
204
  <?php
205
  }
206
 
core/fields/wysiwyg.php CHANGED
@@ -75,7 +75,18 @@ class acf_Wysiwyg extends acf_Field
75
  <script type="text/javascript">
76
  (function($){
77
 
78
- $.fn.setup_wysiwyg = function(){
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  // tinymce must exist
81
  if(!typeof(tinyMCE) == "object")
@@ -91,8 +102,8 @@ class acf_Wysiwyg extends acf_Field
91
  $(this).find('.acf_wysiwyg textarea').each(function(){
92
 
93
  // if this is a repeater clone field, don't set it up!
94
- if(!$(this).closest('tr').hasClass('row_clone'))
95
- {
96
  var toolbar = $(this).closest('.acf_wysiwyg').attr('data-toolbar');
97
 
98
  if(toolbar == 'basic')
@@ -105,8 +116,10 @@ class acf_Wysiwyg extends acf_Field
105
  // add images + code buttons
106
  tinyMCE.settings.theme_advanced_buttons2 += ",code";
107
  }
 
 
108
  tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
109
- }
110
 
111
  // restor rows
112
  tinyMCE.settings.theme_advanced_buttons1 = orig_row_1;
@@ -121,19 +134,20 @@ class acf_Wysiwyg extends acf_Field
121
 
122
  $(document).ready(function(){
123
 
124
- $('#poststuff').setup_wysiwyg();
125
 
126
  // create wysiwyg when you add a repeater row
127
- $('.repeater #add_field').live('click', function(){
128
  //alert('click');
 
129
  var repeater = $(this).closest('.repeater');
130
 
131
  // run after the repeater has added the row
132
  setTimeout(function(){
133
- repeater.children('table').children('tbody').children('tr:last-child').setup_wysiwyg();
134
  }, 1);
135
 
136
- });
137
 
138
  });
139
 
@@ -153,7 +167,15 @@ class acf_Wysiwyg extends acf_Field
153
  tinyMCE.execCommand("mceAddControl", false, $(this).attr('id'));
154
  });
155
 
156
- });
 
 
 
 
 
 
 
 
157
 
158
 
159
  })(jQuery);
@@ -264,16 +286,16 @@ class acf_Wysiwyg extends acf_Field
264
  <div id="media-buttons" class="hide-if-no-js">
265
  Upload/Insert
266
  <a title="Add an Image" class="thickbox" id="add_image" href="media-upload.php?post_id=1802&amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=314">
267
- <img onclick="return false;" alt="Add an Image" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-image.gif?ver=20100531">
268
  </a>
269
  <a title="Add Video" class="thickbox" id="add_video" href="media-upload.php?post_id=1802&amp;type=video&amp;TB_iframe=1&amp;width=640&amp;height=314">
270
- <img onclick="return false;" alt="Add Video" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-video.gif?ver=20100531">
271
  </a>
272
  <a title="Add Audio" class="thickbox" id="add_audio" href="media-upload.php?post_id=1802&amp;type=audio&amp;TB_iframe=1&amp;width=640&amp;height=314">
273
- <img onclick="return false;" alt="Add Audio" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-music.gif?ver=20100531">
274
  </a>
275
  <a title="Add Media" class="thickbox" id="add_media" href="media-upload.php?post_id=1802&amp;TB_iframe=1&amp;width=640&amp;height=314">
276
- <img onclick="return false;" alt="Add Media" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-other.gif?ver=20100531">
277
  </a>
278
  </div>
279
  </div>
75
  <script type="text/javascript">
76
  (function($){
77
 
78
+ $.fn.acf_deactivate_wysiwyg = function(){
79
+
80
+ $(this).find('.acf_wysiwyg textarea').each(function(){
81
+
82
+ tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
83
+
84
+ });
85
+
86
+ };
87
+
88
+
89
+ $.fn.acf_activate_wysiwyg = function(){
90
 
91
  // tinymce must exist
92
  if(!typeof(tinyMCE) == "object")
102
  $(this).find('.acf_wysiwyg textarea').each(function(){
103
 
104
  // if this is a repeater clone field, don't set it up!
105
+ //if(!$(this).closest('tr').hasClass('ignore_setup'))
106
+ //{
107
  var toolbar = $(this).closest('.acf_wysiwyg').attr('data-toolbar');
108
 
109
  if(toolbar == 'basic')
116
  // add images + code buttons
117
  tinyMCE.settings.theme_advanced_buttons2 += ",code";
118
  }
119
+
120
+ tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
121
  tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
122
+ //}
123
 
124
  // restor rows
125
  tinyMCE.settings.theme_advanced_buttons1 = orig_row_1;
134
 
135
  $(document).ready(function(){
136
 
137
+ $('#poststuff').acf_activate_wysiwyg();
138
 
139
  // create wysiwyg when you add a repeater row
140
+ /*$('.repeater #add_field').live('click', function(){
141
  //alert('click');
142
+
143
  var repeater = $(this).closest('.repeater');
144
 
145
  // run after the repeater has added the row
146
  setTimeout(function(){
147
+ repeater.children('table').children('tbody').children('tr:last-child').acf_setup_wysiwyg();
148
  }, 1);
149
 
150
+ });*/
151
 
152
  });
153
 
167
  tinyMCE.execCommand("mceAddControl", false, $(this).attr('id'));
168
  });
169
 
170
+ });
171
+
172
+ // Delete
173
+ $('#poststuff .repeater a.remove_field').live('click', function(event){
174
+
175
+ var tr = $(event.target).closest('tr').find('.acf_wysiwyg textarea').each(function(){
176
+ tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
177
+ });
178
+ });
179
 
180
 
181
  })(jQuery);
286
  <div id="media-buttons" class="hide-if-no-js">
287
  Upload/Insert
288
  <a title="Add an Image" class="thickbox" id="add_image" href="media-upload.php?post_id=1802&amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=314">
289
+ <img onclick="return false;" alt="Add an Image" src="<?php echo $this->parent->wpadminurl; ?>images/media-button-image.gif?ver=20100531">
290
  </a>
291
  <a title="Add Video" class="thickbox" id="add_video" href="media-upload.php?post_id=1802&amp;type=video&amp;TB_iframe=1&amp;width=640&amp;height=314">
292
+ <img onclick="return false;" alt="Add Video" src="<?php echo $this->parent->wpadminurl; ?>images/media-button-video.gif?ver=20100531">
293
  </a>
294
  <a title="Add Audio" class="thickbox" id="add_audio" href="media-upload.php?post_id=1802&amp;type=audio&amp;TB_iframe=1&amp;width=640&amp;height=314">
295
+ <img onclick="return false;" alt="Add Audio" src="<?php echo $this->parent->wpadminurl; ?>images/media-button-music.gif?ver=20100531">
296
  </a>
297
  <a title="Add Media" class="thickbox" id="add_media" href="media-upload.php?post_id=1802&amp;TB_iframe=1&amp;width=640&amp;height=314">
298
+ <img onclick="return false;" alt="Add Media" src="<?php echo $this->parent->wpadminurl; ?>images/media-button-other.gif?ver=20100531">
299
  </a>
300
  </div>
301
  </div>
css/input.css CHANGED
@@ -301,6 +301,9 @@ ul.checkbox_list {
301
  background: transparent !important;
302
  }
303
 
 
 
 
304
 
305
 
306
  /*---------------------------------------------------------------------------------------------
@@ -438,4 +441,175 @@ ul.checkbox_list {
438
 
439
  .acf_relationship .relationship_right .relationship_list a {
440
  cursor: move;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  }
301
  background: transparent !important;
302
  }
303
 
304
+ .repeater tr.row_clone {
305
+ display: none;
306
+ }
307
 
308
 
309
  /*---------------------------------------------------------------------------------------------
441
 
442
  .acf_relationship .relationship_right .relationship_list a {
443
  cursor: move;
444
+ }
445
+
446
+
447
+ /*---------------------------------------------------------------------------------------------
448
+ Flexible Content
449
+ ---------------------------------------------------------------------------------------------*/
450
+ .acf_flexible_content {
451
+
452
+ }
453
+
454
+ .acf_flexible_content > .values > table {
455
+ margin-bottom: 10px;
456
+ position: relative;
457
+ }
458
+
459
+ .acf_flexible_content > .values > table > tbody > tr > td {
460
+ background: transparent;
461
+ border-right: 1px solid #ededed;
462
+ border-bottom: 1px solid #ededed;
463
+ padding: 8px;
464
+ position: relative;
465
+ }
466
+
467
+ .acf_flexible_content > .values > table > tbody > tr:last-child td {
468
+ border-bottom: 0 none;
469
+ }
470
+
471
+ .acf_flexible_content > .values > table > tbody > tr td:last-child{
472
+ border-right: 0 none;
473
+ }
474
+
475
+ .acf_flexible_content > .values > table > tbody > tr:nth-child(even) {
476
+ background: #F9F9F9;
477
+ }
478
+
479
+ .acf_flexible_content > .values > table > tbody > tr:nth-child(odd) {
480
+ background: #FCFCFC;
481
+ }
482
+
483
+ .acf_flexible_content > .values > table > thead > tr > th {
484
+
485
+ border-right: 1px solid #e1e1e1;
486
+ }
487
+
488
+ .acf_flexible_content > .values > table > thead > tr > th:last-child {
489
+ border-right: 0 none;
490
+ }
491
+
492
+ .acf_flexible_content > .values > table > tbody > tr:hover a.remove_field {
493
+ visibility: visible;
494
+ }
495
+
496
+ .acf_flexible_content > .values > table.row_layout > tbody > tr > td > label {
497
+ display: block;
498
+ color: #21759B;
499
+ font-size: 12px;
500
+ font-weight: bold;
501
+ padding: 20px 0 8px;
502
+ text-shadow: 0 1px 0 #FFFFFF;
503
+ }
504
+
505
+ .acf_flexible_content > .values > table.row_layout > tbody > tr > td > label:first-child {
506
+ padding-top: 0;
507
+ }
508
+
509
+ .acf_flexible_content table tr td.order,
510
+ .acf_flexible_content table tr th.order{
511
+ width: 20px;
512
+ text-align: center;
513
+ vertical-align: middle;
514
+ color: #aaa;
515
+ text-shadow: #fff 0 1px 0;
516
+ }
517
+
518
+ .acf_flexible_content table tr td.order {
519
+ cursor: move;
520
+ }
521
+
522
+ .acf_flexible_content table tr td.remove,
523
+ .acf_flexible_content table tr th.remove {
524
+ width: 16px;
525
+ vertical-align: middle;
526
+ }
527
+
528
+ .acf_flexible_content table tr td select {
529
+ width: 120px;
530
+ margin: 0;
531
+ }
532
+
533
+ .acf_flexible_content .clones {
534
+ display: none;
535
+ }
536
+
537
+
538
+ .acf_flexible_content .table_footer {
539
+ position: relative;
540
+ padding: 8px 0;
541
+ }
542
+
543
+ .acf_flexible_content .table_footer a#add_field{
544
+ display: block;
545
+ float: right;
546
+ margin: 0;
547
+ text-align: center;
548
+ }
549
+
550
+ .acf_popup {
551
+ position: absolute;
552
+ bottom: 25px;
553
+ right: 0;
554
+ background: #fff;
555
+ border-radius: 5px;
556
+ box-shadow: rgba(0,0,0,0.25) 0 0 13px;
557
+ margin-bottom: 25px;
558
+ margin-right: -5px;
559
+ display: none;
560
+ }
561
+
562
+ .acf_popup .bit {
563
+ position: absolute;
564
+ width: 56px;
565
+ height: 25px;
566
+ right: 17px;
567
+ margin-bottom: -25px;
568
+ background: url(../images/popup-bit.png);
569
+ }
570
+
571
+ .acf_popup ul {
572
+ display: block;
573
+ margin: 0;
574
+ padding: 0;
575
+ }
576
+
577
+ .acf_popup ul li {
578
+ display: block;
579
+ margin: 0;
580
+ padding: 0;
581
+ }
582
+
583
+ .acf_popup ul li a {
584
+ color: #21759B;
585
+ font-size: 12px;
586
+ line-height: 14px;
587
+ padding: 7px 11px;
588
+ display: block;
589
+ border: 1px solid transparent;
590
+ border-bottom: 1px solid #EDEDED;
591
+ text-decoration: none;
592
+ }
593
+
594
+ .acf_popup ul li:first-child a {
595
+ border-radius: 5px 5px 0 0;
596
+ }
597
+
598
+ .acf_popup ul li:last-child a {
599
+ border-radius: 0 0 5px 5px;
600
+ border-bottom-color: transparent;
601
+ }
602
+
603
+
604
+ .acf_popup ul li a:hover {
605
+ background: url("../images/backgrounds.png") repeat-x scroll 0 0 #6E6E6E;
606
+ border: 1px solid #565656 !important;
607
+ color: #FFFFFF;
608
+ text-shadow: 0 1px 0 #000000;
609
+ }
610
+
611
+ .acf_flexible_content .no_value_message {
612
+ padding: 19px;
613
+ border: #ccc dashed 1px;
614
+ text-align: center;
615
  }
images/popup-bit.png ADDED
Binary file
js/fields.js CHANGED
@@ -85,6 +85,13 @@
85
 
86
  function setup_fields()
87
  {
 
 
 
 
 
 
 
88
 
89
  // add edit button functionality
90
  $('#acf_fields a.acf_edit_field').live('click', function(){
@@ -195,12 +202,12 @@
195
  //alert(sub_field_length);
196
  //alert('update numbers for sub field! field:'+field_length+', sub:'+sub_field_length);
197
 
198
- new_field.update_names(field_length, sub_field_length);
199
  }
200
  else
201
  {
202
  var field_length = fields.children('.field').length;
203
- new_field.update_names(field_length, 0);
204
 
205
  //alert('update numbers for field! field:'+field_length);
206
  }
85
 
86
  function setup_fields()
87
  {
88
+
89
+ function uniqid()
90
+ {
91
+ var newDate = new Date;
92
+ return newDate.getTime();
93
+ }
94
+
95
 
96
  // add edit button functionality
97
  $('#acf_fields a.acf_edit_field').live('click', function(){
202
  //alert(sub_field_length);
203
  //alert('update numbers for sub field! field:'+field_length+', sub:'+sub_field_length);
204
 
205
+ new_field.update_names(uniqid(), uniqid());
206
  }
207
  else
208
  {
209
  var field_length = fields.children('.field').length;
210
+ new_field.update_names(uniqid(), 0);
211
 
212
  //alert('update numbers for field! field:'+field_length);
213
  }
js/input.js CHANGED
@@ -15,7 +15,7 @@
15
  page : false,
16
  post : false,
17
  post_category : false,
18
- post_format : false,
19
  };
20
 
21
 
15
  page : false,
16
  post : false,
17
  post_category : false,
18
+ post_format : false
19
  };
20
 
21
 
readme.txt CHANGED
@@ -94,6 +94,13 @@ http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
 
97
  = 3.0.0 =
98
  * ACF doesn't use any custom tables anymore! All data is saved as post_meta!
99
  * Faster and more stable across different servers
94
 
95
  == Changelog ==
96
 
97
+ = 3.0.1 =
98
+ * Bug Fix - repeater + wysiwyg delete / add duplicate id error
99
+ * Bug fix - repeater + file - add file not working
100
+ * Bug Fix - image / file no longer need the post type to support "editor"
101
+ * WYSIWYG - fixed broken upload images
102
+ * misc updates to accommodate the soon to be released "Flexible Field"
103
+
104
  = 3.0.0 =
105
  * ACF doesn't use any custom tables anymore! All data is saved as post_meta!
106
  * Faster and more stable across different servers