Advanced Custom Fields - Version 3.1.5

Version Description

  • Improvement: Redesigned the experience for uploading and selecting images / files in fields and sub fields. Image / File fields within a repeater can now add multiple images / files
Download this release

Release Info

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

Code changes from version 3.1.4 to 3.1.5

Files changed (5) hide show
  1. acf.php +2 -2
  2. core/fields/file.php +250 -85
  3. core/fields/image.php +259 -84
  4. js/acf.js +0 -0
  5. readme.txt +5 -3
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.1.4
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.1.4';
49
  $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
50
 
51
 
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.1.5
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.1.5';
49
  $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
50
 
51
 
core/fields/file.php CHANGED
@@ -20,21 +20,51 @@ class acf_File extends acf_Field
20
  $this->title = __('File','acf');
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);
@@ -144,7 +174,6 @@ class acf_File extends acf_Field
144
  }
145
 
146
 
147
-
148
  /*---------------------------------------------------------------------------------------------
149
  * popup_head - STYLES MEDIA THICKBOX
150
  *
@@ -153,102 +182,238 @@ class acf_File extends acf_Field
153
  *
154
  ---------------------------------------------------------------------------------------------*/
155
  function popup_head()
156
- {
157
  if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'file')
158
  {
159
- ?>
160
- <style type="text/css">
161
- #media-upload-header #sidemenu li#tab-type_url,
162
- #media-upload-header #sidemenu li#tab-gallery {
163
- display: none;
164
- }
165
-
166
- #media-items tr.url,
167
- #media-items tr.align,
168
- #media-items tr.image_alt,
169
- #media-items tr.image-size,
170
- #media-items tr.post_excerpt,
171
- #media-items tr.post_content,
172
- #media-items tr.image_alt p,
173
- #media-items table thead input.button,
174
- #media-items table thead img.imgedit-wait-spin,
175
- #media-items tr.submit a.wp-post-thumbnail {
176
- display: none;
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
- .media-item table thead img {
180
- border: #DFDFDF solid 1px;
181
- margin-right: 10px;
182
- }
 
 
 
 
 
 
 
 
183
 
184
- </style>
185
- <script type="text/javascript">
186
- (function($){
187
-
188
- $(document).ready(function(){
189
-
190
- $('#media-items').bind('DOMNodeInserted',function(){
191
- $('input[value="Insert into Post"]').each(function(){
192
- $(this).attr('value','<?php _e("Select File",'acf'); ?>');
193
- });
194
- }).trigger('DOMNodeInserted');
195
-
196
- $('form#filter').each(function(){
197
-
198
- $(this).append('<input type="hidden" name="acf_type" value="file" />');
199
-
200
- });
201
- });
202
-
203
- })(jQuery);
204
- </script>
205
 
206
- <?php
207
- }
208
- }
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
 
211
- /*---------------------------------------------------------------------------------------------
212
- * media_send_to_editor - SEND IMAGE TO ACF DIV
213
- *
214
- * @author Elliot Condon
215
- * @since 1.1.4
216
- *
217
- ---------------------------------------------------------------------------------------------*/
218
- function media_send_to_editor($html, $id)
219
- {
220
- parse_str($_POST["_wp_http_referer"], $arr_postinfo);
221
 
222
- if(isset($arr_postinfo["acf_type"]) && $arr_postinfo["acf_type"] == "file")
 
 
223
  {
224
-
225
- $file_src = wp_get_attachment_url($id);
 
226
 
227
- ?>
228
- <script type="text/javascript">
229
-
230
- self.parent.acf_div.find('input.value').val('<?php echo $id; ?>');
231
- self.parent.acf_div.find('span.file_url').text('<?php echo $file_src; ?>');
232
- self.parent.acf_div.addClass('active');
233
-
234
- // validation
235
- self.parent.acf_div.closest('.field').removeClass('error');
236
-
237
- // reset acf_div and return false
238
- self.parent.acf_div = null;
239
- self.parent.tb_remove();
 
 
 
240
 
241
- </script>
242
- <?php
243
- exit;
244
- }
245
- else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  {
247
- return $html;
248
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
 
252
  /*--------------------------------------------------------------------------------------
253
  *
254
  * get_value_for_api
20
  $this->title = __('File','acf');
21
 
22
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
23
+ add_action('wp_ajax_acf_select_file', array($this, 'select_file'));
24
+ add_filter('get_media_item_args', array($this, 'allow_file_insertion'));
25
+ }
26
+
27
+
28
+ /*--------------------------------------------------------------------------------------
29
+ *
30
+ * select_file
31
+ *
32
+ * @description ajax function to provide url of selected file
33
+ * @author Elliot Condon
34
+ * @since 3.1.5
35
+ *
36
+ *-------------------------------------------------------------------------------------*/
37
+
38
+ function select_file()
39
+ {
40
+ $id = isset($_POST['id']) ? $_POST['id'] : false;
41
+
42
+
43
+ // attachment ID is required
44
+ if(!$id)
45
+ {
46
+ echo "";
47
+ die();
48
+ }
49
+
50
+
51
+ $file_src = wp_get_attachment_url($id);
52
+
53
+ echo $file_src;
54
+ die();
55
  }
56
 
57
 
58
  /*--------------------------------------------------------------------------------------
59
  *
60
+ * allow_file_insertion
61
  *
62
  * @author Elliot Condon
63
  * @since 3.0.1
64
  *
65
  *-------------------------------------------------------------------------------------*/
66
 
67
+ function allow_file_insertion($vars)
68
  {
69
  $vars['send'] = true;
70
  return($vars);
174
  }
175
 
176
 
 
177
  /*---------------------------------------------------------------------------------------------
178
  * popup_head - STYLES MEDIA THICKBOX
179
  *
182
  *
183
  ---------------------------------------------------------------------------------------------*/
184
  function popup_head()
185
+ {
186
  if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'file')
187
  {
188
+ $tab = isset($_GET['tab']) ? $_GET['tab'] : "type"; // "type" is the upload tab
189
+
190
+ ?><style type="text/css">
191
+ #media-upload-header #sidemenu li#tab-type_url,
192
+ #media-upload-header #sidemenu li#tab-gallery,
193
+ #media-items .media-item table.slidetoggle,
194
+ #media-items .media-item a.toggle {
195
+ display: none !important;
196
+ }
197
+
198
+ #media-items .media-item {
199
+ min-height: 68px;
200
+ }
201
+
202
+ #media-items .media-item .acf-checkbox {
203
+ float: left;
204
+ margin: 28px 10px 0;
205
+ }
206
+
207
+ #media-items .media-item .pinkynail {
208
+ max-width: 64px;
209
+ max-height: 64px;
210
+ display: block !important;
211
+ }
212
+
213
+ #media-items .media-item .filename.new {
214
+ min-height: 0;
215
+ padding: 25px 10px 10px;
216
+ line-height: 14px;
217
+
218
+ }
219
+
220
+ #media-items .media-item .title {
221
+ line-height: 14px;
222
+ }
223
+
224
+ #media-items .media-item .button {
225
+ float: right;
226
+ margin: -2px 0 0 10px;
227
+ }
228
+
229
+ #media-upload .ml-submit {
230
+ display: none !important;
231
+ }
232
 
233
+ #media-upload .acf-submit {
234
+ margin: 1em 0;
235
+ padding: 1em 0;
236
+ position: relative;
237
+ overflow: hidden;
238
+ display: none; /* default is hidden */
239
+ }
240
+
241
+ #media-upload .acf-submit a {
242
+ float: left;
243
+ margin: 0 10px 0 0;
244
+ }
245
 
246
+ </style>
247
+ <script type="text/javascript">
248
+ (function($){
249
+
250
+ //console.log(window.plupload);
251
+ $('#media-items .media-item .filename a.acf-select').live('click', function(){
252
+
253
+ var id = $(this).attr('href');
254
+
255
+ var data = {
256
+ action: 'acf_select_file',
257
+ id: id
258
+ };
259
+
260
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
261
+ $.post(ajaxurl, data, function(html) {
262
+
263
+ if(!html || html == "")
264
+ {
265
+ return false;
266
+ }
267
 
268
+ self.parent.acf_div.find('input.value').val(id);
269
+ self.parent.acf_div.find('span.file_url').text(html);
270
+ self.parent.acf_div.addClass('active');
271
+
272
+ // validation
273
+ self.parent.acf_div.closest('.field').removeClass('error');
274
+
275
+ // reset acf_div and return false
276
+ self.parent.acf_div = null;
277
+ self.parent.tb_remove();
278
+
279
+ });
280
+
281
+ return false;
282
+ });
283
 
284
 
285
+ $('#acf-add-selected').live('click', function(){
 
 
 
 
 
 
 
 
 
286
 
287
+ // check total
288
+ var total = $('#media-items .media-item .acf-checkbox:checked').length;
289
+ if(total == 0)
290
  {
291
+ alert("<?php _e("No Files Selected",'acf'); ?>");
292
+ return false;
293
+ }
294
 
295
+ $('#media-items .media-item .acf-checkbox:checked').each(function(i){
296
+
297
+ var id = $(this).val();
298
+
299
+ var data = {
300
+ action: 'acf_select_image',
301
+ id: id
302
+ };
303
+
304
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
305
+ $.post(ajaxurl, data, function(html) {
306
+
307
+ if(!html || html == "")
308
+ {
309
+ return false;
310
+ }
311
 
312
+ self.parent.acf_div.find('input.value').val(id);
313
+ self.parent.acf_div.find('span.file_url').text(html);
314
+ self.parent.acf_div.addClass('active');
315
+
316
+ // validation
317
+ self.parent.acf_div.closest('.field').removeClass('error');
318
+
319
+ if((i+1) < total)
320
+ {
321
+ // add row
322
+ self.parent.acf_div.closest('.repeater').find('.table_footer #r_add_row').trigger('click');
323
+
324
+ // set acf_div to new row image
325
+ self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('table tbody tr.row:last-child .acf_file_uploader');
326
+ }
327
+ else
328
+ {
329
+ // reset acf_div and return false
330
+ self.parent.acf_div = null;
331
+ self.parent.tb_remove();
332
+ }
333
+
334
+
335
+ });
336
+
337
+ });
338
+
339
+
340
+ return false;
341
+
342
+ });
343
+
344
+
345
+ // set a interval function to add buttons to media items
346
+ function acf_add_buttons()
347
+ {
348
+ // vars
349
+ var is_sub_field = (self.parent.acf_div && self.parent.acf_div.closest('.repeater').length > 0) ? true : false;
350
+
351
+
352
+ // add submit after media items (on for sub fields)
353
+ if($('.acf-submit').length == 0 && is_sub_field)
354
  {
355
+ $('#media-items').after('<div class="acf-submit"><a id="acf-add-selected" class="button"><?php _e("Add Selected Files",'acf'); ?></a></div>');
356
  }
357
+
358
+
359
+ // add buttons to media items
360
+ $('#media-items .media-item:not(.acf-active)').each(function(){
361
+
362
+ // show the add all button
363
+ $('.acf-submit').show();
364
+
365
+ // needs attachment ID
366
+ if($(this).children('input[id*="type-of-"]').length == 0){ return false; }
367
+
368
+ // only once!
369
+ $(this).addClass('acf-active');
370
+
371
+ // find id
372
+ var id = $(this).children('input[id*="type-of-"]').attr('id').replace('type-of-', '');
373
+
374
+ // if inside repeater, add checkbox
375
+ if(is_sub_field)
376
+ {
377
+ $(this).prepend('<input type="checkbox" class="acf-checkbox" value="' + id + '" <?php if($tab == "type"){echo 'checked="checked"';} ?> />');
378
+ }
379
+
380
+ // change text of insert button, and add new button
381
+ $(this).find('.filename.new').append('<a href="' + id + '" class="button acf-select"><?php _e("Select File",'acf'); ?></a>');
382
+
383
+ });
384
  }
385
+ <?php
386
+
387
+ // run the acf_add_buttons ever 500ms when on the image upload tab
388
+ if($tab == 'type'): ?>
389
+ var acf_t = setInterval(function(){
390
+ acf_add_buttons();
391
+ }, 500);
392
+ <?php endif; ?>
393
+
394
+
395
+ // add acf input filters to allow for tab navigation
396
+ $(document).ready(function(){
397
+
398
+ setTimeout(function(){
399
+ acf_add_buttons();
400
+ }, 1);
401
 
402
+
403
+ $('form#filter, form#image-form').each(function(){
404
+
405
+ $(this).append('<input type="hidden" name="acf_type" value="file" />');
406
+
407
+ });
408
+ });
409
+
410
+ })(jQuery);
411
+ </script><?php
412
+
413
+ }
414
+ }
415
 
416
+
417
  /*--------------------------------------------------------------------------------------
418
  *
419
  * get_value_for_api
core/fields/image.php CHANGED
@@ -21,11 +21,43 @@ class acf_Image extends acf_Field
21
  $this->title = __('Image','acf');
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
@@ -164,7 +196,6 @@ class acf_Image extends acf_Field
164
  ?>
165
  </td>
166
  </tr>
167
-
168
  <?php
169
  }
170
 
@@ -178,105 +209,249 @@ class acf_Image extends acf_Field
178
  *
179
  ---------------------------------------------------------------------------------------------*/
180
  function popup_head()
181
- {
182
  if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'image')
183
  {
184
- $preview_size = isset($arr_postinfo['preview_size']) ? $arr_postinfo['preview_size'] : 'medium';
 
185
 
186
- ?>
187
- <style type="text/css">
188
- #media-upload-header #sidemenu li#tab-type_url,
189
- #media-upload-header #sidemenu li#tab-gallery {
190
- display: none;
191
- }
192
-
193
- #media-items tr.url,
194
- #media-items tr.align,
195
- #media-items tr.image_alt,
196
- #media-items tr.image-size,
197
- #media-items tr.post_excerpt,
198
- #media-items tr.post_content,
199
- #media-items tr.image_alt p,
200
- #media-items table thead input.button,
201
- #media-items table thead img.imgedit-wait-spin,
202
- #media-items tr.submit a.wp-post-thumbnail {
203
- display: none;
204
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
- .media-item table thead img {
207
- border: #DFDFDF solid 1px;
208
- margin-right: 10px;
209
- }
 
 
 
 
 
 
 
 
210
 
211
- </style>
212
- <script type="text/javascript">
213
- (function($){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
- $(document).ready(function(){
216
-
217
- $('#media-items').bind('DOMNodeInserted',function(){
218
- $('input[value="Insert into Post"]').each(function(){
219
- $(this).attr('value','<?php _e("Select Image",'acf'); ?>');
220
- });
221
- }).trigger('DOMNodeInserted');
222
-
223
- $('form#filter').each(function(){
224
-
225
- $(this).append('<input type="hidden" name="acf_preview_size" value="<?php echo $preview_size; ?>" />');
226
- $(this).append('<input type="hidden" name="acf_type" value="image" />');
227
-
228
- });
229
- });
230
-
231
- })(jQuery);
232
- </script>
233
- <?php
234
- }
235
- }
236
 
237
 
238
- /*---------------------------------------------------------------------------------------------
239
- * media_send_to_editor - SEND IMAGE TO ACF DIV
240
- *
241
- * @author Elliot Condon
242
- * @since 1.1.4
243
- *
244
- ---------------------------------------------------------------------------------------------*/
245
- function media_send_to_editor($html, $id)
246
- {
247
- parse_str($_POST["_wp_http_referer"], $arr_postinfo);
248
 
249
- if(isset($arr_postinfo["acf_type"]) && $arr_postinfo["acf_type"] == "image")
 
 
250
  {
 
 
 
 
 
251
 
252
- $preview_size = isset($arr_postinfo['acf_preview_size']) ? $arr_postinfo['acf_preview_size'] : 'medium';
253
 
254
- $file_src = wp_get_attachment_image_src($id, $preview_size);
255
- $file_src = $file_src[0];
 
 
 
256
 
257
- ?>
258
- <script type="text/javascript">
259
-
260
- self.parent.acf_div.find('input.value').val('<?php echo $id; ?>');
261
- self.parent.acf_div.find('img').attr('src','<?php echo $file_src; ?>');
262
- self.parent.acf_div.addClass('active');
263
-
264
- // validation
265
- self.parent.acf_div.closest('.field').removeClass('error');
266
-
267
- // reset acf_div and return false
268
- self.parent.acf_div = null;
269
- self.parent.tb_remove();
270
 
271
- </script>
272
- <?php
273
- exit;
274
- }
275
- else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  {
277
- return $html;
278
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
 
280
  }
281
 
282
 
21
  $this->title = __('Image','acf');
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
+ add_action('wp_ajax_acf_select_image', array($this, 'select_image'));
25
  add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
26
  }
27
 
28
 
29
+ /*--------------------------------------------------------------------------------------
30
+ *
31
+ * select_image
32
+ *
33
+ * @description ajax function to provide url of selected image
34
+ * @author Elliot Condon
35
+ * @since 3.1.5
36
+ *
37
+ *-------------------------------------------------------------------------------------*/
38
+
39
+ function select_image()
40
+ {
41
+ $id = isset($_POST['id']) ? $_POST['id'] : false;
42
+ $preview_size = isset($_POST['preview_size']) ? $_POST['preview_size'] : 'medium';
43
+
44
+
45
+ // attachment ID is required
46
+ if(!$id)
47
+ {
48
+ echo "";
49
+ die();
50
+ }
51
+
52
+
53
+ $file_src = wp_get_attachment_image_src($id, $preview_size);
54
+ $file_src = $file_src[0];
55
+
56
+ echo $file_src;
57
+ die();
58
+ }
59
+
60
+
61
  /*--------------------------------------------------------------------------------------
62
  *
63
  * admin_print_scripts / admin_print_styles
196
  ?>
197
  </td>
198
  </tr>
 
199
  <?php
200
  }
201
 
209
  *
210
  ---------------------------------------------------------------------------------------------*/
211
  function popup_head()
212
+ {
213
  if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'image')
214
  {
215
+ $tab = isset($_GET['tab']) ? $_GET['tab'] : "type"; // "type" is the upload tab
216
+ $preview_size = isset($_GET['acf_preview_size']) ? $_GET['acf_preview_size'] : 'medium';
217
 
218
+ ?><style type="text/css">
219
+ #media-upload-header #sidemenu li#tab-type_url,
220
+ #media-upload-header #sidemenu li#tab-gallery,
221
+ #media-items .media-item table.slidetoggle,
222
+ #media-items .media-item a.toggle {
223
+ display: none !important;
224
+ }
225
+
226
+ #media-items .media-item {
227
+ min-height: 68px;
228
+ }
229
+
230
+ #media-items .media-item .acf-checkbox {
231
+ float: left;
232
+ margin: 28px 10px 0;
233
+ }
234
+
235
+ #media-items .media-item .pinkynail {
236
+ max-width: 64px;
237
+ max-height: 64px;
238
+ display: block !important;
239
+ }
240
+
241
+ #media-items .media-item .filename.new {
242
+ min-height: 0;
243
+ padding: 25px 10px 10px;
244
+ line-height: 14px;
245
+
246
+ }
247
+
248
+ #media-items .media-item .title {
249
+ line-height: 14px;
250
+ }
251
+
252
+ #media-items .media-item .button {
253
+ float: right;
254
+ margin: -2px 0 0 10px;
255
+ }
256
+
257
+ #media-upload .ml-submit {
258
+ display: none !important;
259
+ }
260
 
261
+ #media-upload .acf-submit {
262
+ margin: 1em 0;
263
+ padding: 1em 0;
264
+ position: relative;
265
+ overflow: hidden;
266
+ display: none; /* default is hidden */
267
+ }
268
+
269
+ #media-upload .acf-submit a {
270
+ float: left;
271
+ margin: 0 10px 0 0;
272
+ }
273
 
274
+ </style>
275
+ <script type="text/javascript">
276
+ (function($){
277
+
278
+ //console.log(window.plupload);
279
+ $('#media-items .media-item .filename a.acf-select').live('click', function(){
280
+
281
+ var id = $(this).attr('href');
282
+
283
+ var data = {
284
+ action: 'acf_select_image',
285
+ id: id,
286
+ preview_size : "<?php echo $preview_size; ?>"
287
+ };
288
+
289
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
290
+ $.post(ajaxurl, data, function(html) {
291
+
292
+ if(!html || html == "")
293
+ {
294
+ return false;
295
+ }
296
 
297
+ self.parent.acf_div.find('input.value').val(id);
298
+ self.parent.acf_div.find('img').attr('src',html);
299
+ self.parent.acf_div.addClass('active');
300
+
301
+ // validation
302
+ self.parent.acf_div.closest('.field').removeClass('error');
303
+
304
+ // reset acf_div and return false
305
+ self.parent.acf_div = null;
306
+ self.parent.tb_remove();
307
+
308
+ });
309
+
310
+ return false;
311
+ });
 
 
 
 
 
 
312
 
313
 
314
+ $('#acf-add-selected').live('click', function(){
 
 
 
 
 
 
 
 
 
315
 
316
+ // check total
317
+ var total = $('#media-items .media-item .acf-checkbox:checked').length;
318
+ if(total == 0)
319
  {
320
+ alert("<?php _e("No images selected",'acf'); ?>");
321
+ return false;
322
+ }
323
+
324
+ $('#media-items .media-item .acf-checkbox:checked').each(function(i){
325
 
326
+ var id = $(this).val();
327
 
328
+ var data = {
329
+ action: 'acf_select_image',
330
+ id: id,
331
+ preview_size : "<?php echo $preview_size; ?>"
332
+ };
333
 
334
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
335
+ $.post(ajaxurl, data, function(html) {
336
+
337
+ if(!html || html == "")
338
+ {
339
+ return false;
340
+ }
 
 
 
 
 
 
341
 
342
+ self.parent.acf_div.find('input.value').val(id);
343
+ self.parent.acf_div.find('img').attr('src',html);
344
+ self.parent.acf_div.addClass('active');
345
+
346
+ // validation
347
+ self.parent.acf_div.closest('.field').removeClass('error');
348
+
349
+ if((i+1) < total)
350
+ {
351
+ // add row
352
+ self.parent.acf_div.closest('.repeater').find('.table_footer #r_add_row').trigger('click');
353
+
354
+ // set acf_div to new row image
355
+ self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('table tbody tr.row:last-child .acf_image_uploader');
356
+ }
357
+ else
358
+ {
359
+ // reset acf_div and return false
360
+ self.parent.acf_div = null;
361
+ self.parent.tb_remove();
362
+ }
363
+
364
+
365
+ });
366
+
367
+ });
368
+
369
+
370
+ return false;
371
+
372
+ });
373
+
374
+
375
+ // set a interval function to add buttons to media items
376
+ function acf_add_buttons()
377
+ {
378
+ // vars
379
+ var is_sub_field = (self.parent.acf_div && self.parent.acf_div.closest('.repeater').length > 0) ? true : false;
380
+
381
+
382
+ // add submit after media items (on for sub fields)
383
+ if($('.acf-submit').length == 0 && is_sub_field)
384
  {
385
+ $('#media-items').after('<div class="acf-submit"><a id="acf-add-selected" class="button"><?php _e("Add selected Images",'acf'); ?></a></div>');
386
  }
387
+
388
+
389
+ // add buttons to media items
390
+ $('#media-items .media-item:not(.acf-active)').each(function(){
391
+
392
+ // show the add all button
393
+ $('.acf-submit').show();
394
+
395
+ // needs attachment ID
396
+ if($(this).children('input[id*="type-of-"]').length == 0){ return false; }
397
+
398
+ // only once!
399
+ $(this).addClass('acf-active');
400
+
401
+ // find id
402
+ var id = $(this).children('input[id*="type-of-"]').attr('id').replace('type-of-', '');
403
+
404
+ // if inside repeater, add checkbox
405
+ if(is_sub_field)
406
+ {
407
+ $(this).prepend('<input type="checkbox" class="acf-checkbox" value="' + id + '" <?php if($tab == "type"){echo 'checked="checked"';} ?> />');
408
+ }
409
+
410
+ // change text of insert button, and add new button
411
+ $(this).find('.filename.new').append('<a href="' + id + '" class="button acf-select"><?php _e("Select Image",'acf'); ?></a>');
412
+
413
+ });
414
+ }
415
+ <?php
416
+
417
+ // run the acf_add_buttons ever 500ms when on the image upload tab
418
+ if($tab == 'type'): ?>
419
+ var acf_t = setInterval(function(){
420
+ acf_add_buttons();
421
+ }, 500);
422
+ <?php endif; ?>
423
+
424
+
425
+ // add acf input filters to allow for tab navigation
426
+ $(document).ready(function(){
427
+
428
+ setTimeout(function(){
429
+ acf_add_buttons();
430
+ }, 1);
431
+
432
+
433
+ $('form#filter, form#image-form').each(function(){
434
+
435
+ $(this).append('<input type="hidden" name="acf_preview_size" value="<?php echo $preview_size; ?>" />');
436
+ $(this).append('<input type="hidden" name="acf_type" value="image" />');
437
+
438
+ /*var action = $(this).attr('action');
439
+ if(action.indexOf("acf_type") == -1)
440
+ {
441
+ action += "&acf_type=image";
442
+ }
443
+ if(action.indexOf("acf_preview_size") == -1)
444
+ {
445
+ action += "&acf_preview_size=<?php echo $preview_size; ?>";
446
+ }
447
+ $(this).attr('action', action);*/
448
+ });
449
+ });
450
+
451
+ })(jQuery);
452
+ </script><?php
453
 
454
+ }
455
  }
456
 
457
 
js/acf.js DELETED
File without changes
readme.txt CHANGED
@@ -62,9 +62,8 @@ Your votes really make a difference! Thanks.
62
 
63
  1. Upload 'advanced-custom-fields' to the '/wp-content/plugins/' directory
64
  2. Activate the plugin through the 'Plugins' menu in WordPress
65
- 3. You may be prompted for a Database Upgrade. This is necessary for ACF to function. Please backup your database and click the Upgrade button
66
- 3. Click on Adv Custom Fields and create your first Custom Field Group!
67
- 4. Your ACF field group will now appear on the page / post / template you specified in the field group's location rules!
68
  5. Read the documentation to display your data:
69
 
70
 
@@ -87,6 +86,9 @@ http://www.advancedcustomfields.com/support/
87
 
88
  == Changelog ==
89
 
 
 
 
90
  = 3.1.4 =
91
  * New Feature: Front end form (Please read documentation on website for usage)
92
  * Performance: compiled all field script / style into 1 .js file
62
 
63
  1. Upload 'advanced-custom-fields' to the '/wp-content/plugins/' directory
64
  2. Activate the plugin through the 'Plugins' menu in WordPress
65
+ 3. Click on the new menu itme "Custom Fields" and create your first Custom Field Group!
66
+ 4. Your custom field group will now appear on the page / post / template you specified in the field group's location rules!
 
67
  5. Read the documentation to display your data:
68
 
69
 
86
 
87
  == Changelog ==
88
 
89
+ = 3.1.5 =
90
+ * Improvement: Redesigned the experience for uploading and selecting images / files in fields and sub fields. Image / File fields within a repeater can now add multiple images / files
91
+
92
  = 3.1.4 =
93
  * New Feature: Front end form (Please read documentation on website for usage)
94
  * Performance: compiled all field script / style into 1 .js file