Version Description
- Bug fix: Image field returns correct url after selecting one or more images
- Translation: Added Polish translation. Thank you Bartosz Arendt - Digital Factory - www.digitalfactory.pl
- Update : Added id attribute to all div.field (id="acf-$field_name")
Download this release
Release Info
Developer | elliotcondon |
Plugin | Advanced Custom Fields |
Version | 3.1.7 |
Comparing to | |
See all releases |
Code changes from version 3.1.6 to 3.1.7
- acf.php +3 -3
- core/fields/image.php +172 -54
- core/fields/relationship.php +5 -0
- lang/acf-pl_PL.mo +0 -0
- readme.txt +5 -0
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.
|
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.
|
49 |
$this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
|
50 |
|
51 |
|
@@ -1829,7 +1829,7 @@ class Acf
|
|
1829 |
$required_label = ' <span class="required">*</span>';
|
1830 |
}
|
1831 |
|
1832 |
-
echo '<div class="field field-' . $field['type'] . $required_class . '">';
|
1833 |
|
1834 |
echo '<label class="field_label" for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
|
1835 |
if($field['instructions']) echo '<p class="instructions">' . $field['instructions'] . '</p>';
|
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.7
|
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.7';
|
49 |
$this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
|
50 |
|
51 |
|
1829 |
$required_label = ' <span class="required">*</span>';
|
1830 |
}
|
1831 |
|
1832 |
+
echo '<div id="acf-' . $field['name'] . '" class="field field-' . $field['type'] . $required_class . '">';
|
1833 |
|
1834 |
echo '<label class="field_label" for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
|
1835 |
if($field['instructions']) echo '<p class="instructions">' . $field['instructions'] . '</p>';
|
core/fields/image.php
CHANGED
@@ -22,6 +22,55 @@ class acf_Image extends acf_Field
|
|
22 |
|
23 |
add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
|
24 |
add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
|
@@ -85,7 +134,7 @@ class acf_Image extends acf_Field
|
|
85 |
// vars
|
86 |
$class = "";
|
87 |
$file_src = "";
|
88 |
-
$preview_size = isset($field['preview_size']) ? $field['preview_size'] : '
|
89 |
|
90 |
// get image url
|
91 |
if($field['value'] != '' && is_numeric($field['value']))
|
@@ -180,7 +229,7 @@ class acf_Image extends acf_Field
|
|
180 |
if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'image')
|
181 |
{
|
182 |
$tab = isset($_GET['tab']) ? $_GET['tab'] : "type"; // "type" is the upload tab
|
183 |
-
$preview_size = isset($_GET['acf_preview_size']) ? $_GET['acf_preview_size'] : '
|
184 |
|
185 |
?><style type="text/css">
|
186 |
#media-upload-header #sidemenu li#tab-type_url,
|
@@ -249,6 +298,39 @@ class acf_Image extends acf_Field
|
|
249 |
// generate the preview size (150x150)
|
250 |
var preview_size = "<?php echo get_option($preview_size . '_size_w'); ?>x<?php echo get_option($preview_size . '_size_h'); ?>";
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
/*
|
254 |
* Select Image
|
@@ -259,28 +341,45 @@ class acf_Image extends acf_Field
|
|
259 |
$('#media-items .media-item .filename a.acf-select').live('click', function(){
|
260 |
|
261 |
var id = $(this).attr('href');
|
262 |
-
var src = $(this).closest('.media-item').find('img').attr('src');
|
263 |
-
|
264 |
-
|
265 |
-
// image will be thumbnail size, find last 150x150.png and replace with 150x150.png
|
266 |
-
src = src.replace(/-([0-9]+)x([0-9]+)\.([a-zA-Z]{2,4})/, "-" + preview_size + ".$3");
|
267 |
-
|
268 |
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
//
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
return false;
|
|
|
284 |
});
|
285 |
|
286 |
|
@@ -295,43 +394,62 @@ class acf_Image extends acf_Field
|
|
295 |
}
|
296 |
|
297 |
|
298 |
-
//
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
-
//
|
306 |
-
|
|
|
|
|
|
|
307 |
|
|
|
308 |
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
-
|
319 |
-
|
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_image_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 |
return false;
|
337 |
|
22 |
|
23 |
add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
|
24 |
add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
|
25 |
+
add_action('wp_ajax_acf_get_preview_image', array($this, 'acf_get_preview_image'));
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/*--------------------------------------------------------------------------------------
|
30 |
+
*
|
31 |
+
* acf_get_preview_image
|
32 |
+
*
|
33 |
+
* @description Returns a json array of preview sized urls
|
34 |
+
* @author Elliot Condon
|
35 |
+
* @since 3.1.7
|
36 |
+
*
|
37 |
+
*-------------------------------------------------------------------------------------*/
|
38 |
+
|
39 |
+
function acf_get_preview_image()
|
40 |
+
{
|
41 |
+
// vars
|
42 |
+
$id_string = isset($_GET['id']) ? $_GET['id'] : false;
|
43 |
+
$preview_size = isset($_GET['preview_size']) ? $_GET['preview_size'] : 'thumbnail';
|
44 |
+
$return = array();
|
45 |
+
|
46 |
+
|
47 |
+
// attachment ID is required
|
48 |
+
if($id_string)
|
49 |
+
{
|
50 |
+
|
51 |
+
// convert id_string into an array
|
52 |
+
$id_array = explode(',' , $id_string);
|
53 |
+
if(!is_array($id_array))
|
54 |
+
{
|
55 |
+
$id_array = array( $id_string );
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
// find image preview url for each image
|
60 |
+
foreach($id_array as $id)
|
61 |
+
{
|
62 |
+
$file_src = wp_get_attachment_image_src($id, $preview_size);
|
63 |
+
$return[] = array(
|
64 |
+
'id' => $id,
|
65 |
+
'url' => $file_src[0],
|
66 |
+
);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
// return json
|
72 |
+
echo json_encode( $return );
|
73 |
+
die();
|
74 |
}
|
75 |
|
76 |
|
134 |
// vars
|
135 |
$class = "";
|
136 |
$file_src = "";
|
137 |
+
$preview_size = isset($field['preview_size']) ? $field['preview_size'] : 'thumbnail';
|
138 |
|
139 |
// get image url
|
140 |
if($field['value'] != '' && is_numeric($field['value']))
|
229 |
if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'image')
|
230 |
{
|
231 |
$tab = isset($_GET['tab']) ? $_GET['tab'] : "type"; // "type" is the upload tab
|
232 |
+
$preview_size = isset($_GET['acf_preview_size']) ? $_GET['acf_preview_size'] : 'thumbnail';
|
233 |
|
234 |
?><style type="text/css">
|
235 |
#media-upload-header #sidemenu li#tab-type_url,
|
298 |
// generate the preview size (150x150)
|
299 |
var preview_size = "<?php echo get_option($preview_size . '_size_w'); ?>x<?php echo get_option($preview_size . '_size_h'); ?>";
|
300 |
|
301 |
+
|
302 |
+
|
303 |
+
/*
|
304 |
+
* get_preview_image
|
305 |
+
*
|
306 |
+
* @created : 6/04/2012
|
307 |
+
|
308 |
+
function get_preview_image(options, callback)
|
309 |
+
{
|
310 |
+
// defaults
|
311 |
+
var defaults = {
|
312 |
+
id : [],
|
313 |
+
preview_size : "thumbnail",
|
314 |
+
};
|
315 |
+
|
316 |
+
|
317 |
+
// override deafault with options
|
318 |
+
$.extend(defaults, options);
|
319 |
+
|
320 |
+
|
321 |
+
// run ajax to get id urls
|
322 |
+
$.ajax({
|
323 |
+
url : ajaxurl
|
324 |
+
data : options,
|
325 |
+
dataType : "json",
|
326 |
+
type : "POST",
|
327 |
+
|
328 |
+
|
329 |
+
});
|
330 |
+
|
331 |
+
|
332 |
+
}
|
333 |
+
*/
|
334 |
|
335 |
/*
|
336 |
* Select Image
|
341 |
$('#media-items .media-item .filename a.acf-select').live('click', function(){
|
342 |
|
343 |
var id = $(this).attr('href');
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
+
var data = {
|
346 |
+
action: 'acf_get_preview_image',
|
347 |
+
id: id,
|
348 |
+
preview_size : "<?php echo $preview_size; ?>"
|
349 |
+
};
|
350 |
+
|
351 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
352 |
+
$.getJSON(ajaxurl, data, function( json ) {
|
353 |
+
|
354 |
+
// validate
|
355 |
+
if(!json)
|
356 |
+
{
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
|
361 |
+
// get item
|
362 |
+
item = json[0];
|
363 |
+
|
364 |
+
|
365 |
+
// update acf_div
|
366 |
+
self.parent.acf_div.find('input.value').val( item.id );
|
367 |
+
self.parent.acf_div.find('img').attr( 'src', item.url );
|
368 |
+
self.parent.acf_div.addClass('active');
|
369 |
+
|
370 |
+
|
371 |
+
// validation
|
372 |
+
self.parent.acf_div.closest('.field').removeClass('error');
|
373 |
+
|
374 |
+
|
375 |
+
// reset acf_div and return false
|
376 |
+
self.parent.acf_div = null;
|
377 |
+
self.parent.tb_remove();
|
378 |
+
|
379 |
+
});
|
380 |
|
381 |
return false;
|
382 |
+
|
383 |
});
|
384 |
|
385 |
|
394 |
}
|
395 |
|
396 |
|
397 |
+
// generate id's
|
398 |
+
var attachment_ids = [];
|
399 |
+
$('#media-items .media-item .acf-checkbox:checked').each(function(){
|
400 |
+
attachment_ids.push( $(this).val() );
|
401 |
+
});
|
402 |
+
|
403 |
+
|
404 |
+
// creae json data
|
405 |
+
var data = {
|
406 |
+
action: 'acf_get_preview_image',
|
407 |
+
id: attachment_ids.join(','),
|
408 |
+
preview_size : "<?php echo $preview_size; ?>"
|
409 |
+
};
|
410 |
+
|
411 |
+
|
412 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
413 |
+
$.getJSON(ajaxurl, data, function( json ) {
|
414 |
|
415 |
+
// validate
|
416 |
+
if(!json)
|
417 |
+
{
|
418 |
+
return false;
|
419 |
+
}
|
420 |
|
421 |
+
$.each(json, function(i ,item){
|
422 |
|
423 |
+
// update acf_div
|
424 |
+
self.parent.acf_div.find('input.value').val( item.id );
|
425 |
+
self.parent.acf_div.find('img').attr('src', item.url );
|
426 |
+
self.parent.acf_div.addClass('active');
|
427 |
+
|
428 |
+
|
429 |
+
// validation
|
430 |
+
self.parent.acf_div.closest('.field').removeClass('error');
|
431 |
+
|
432 |
+
|
433 |
+
if((i+1) < total)
|
434 |
+
{
|
435 |
+
// add row
|
436 |
+
self.parent.acf_div.closest('.repeater').find('.table_footer #r_add_row').trigger('click');
|
437 |
+
|
438 |
+
// set acf_div to new row image
|
439 |
+
self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr.row:last-child .acf_image_uploader');
|
440 |
+
}
|
441 |
+
else
|
442 |
+
{
|
443 |
+
// reset acf_div and return false
|
444 |
+
self.parent.acf_div = null;
|
445 |
+
self.parent.tb_remove();
|
446 |
+
}
|
447 |
+
|
448 |
+
});
|
449 |
|
450 |
+
|
451 |
+
|
452 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
return false;
|
455 |
|
core/fields/relationship.php
CHANGED
@@ -179,6 +179,11 @@ class acf_Relationship extends acf_Field
|
|
179 |
{
|
180 |
foreach($values_array as $value)
|
181 |
{
|
|
|
|
|
|
|
|
|
|
|
182 |
$post = $temp_posts[$value];
|
183 |
|
184 |
$title = get_the_title($post->ID);
|
179 |
{
|
180 |
foreach($values_array as $value)
|
181 |
{
|
182 |
+
if(!isset($temp_posts[$value]))
|
183 |
+
{
|
184 |
+
continue;
|
185 |
+
}
|
186 |
+
|
187 |
$post = $temp_posts[$value];
|
188 |
|
189 |
$title = get_the_title($post->ID);
|
lang/acf-pl_PL.mo
ADDED
Binary file
|
readme.txt
CHANGED
@@ -86,6 +86,11 @@ http://www.advancedcustomfields.com/support/
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
|
|
|
|
89 |
= 3.1.6 =
|
90 |
* New style for buttons
|
91 |
* Bug Fix: Repeater maximum row setting was disabling the "add row" button 1 row early.
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 3.1.7 =
|
90 |
+
* Bug fix: Image field returns correct url after selecting one or more images
|
91 |
+
* Translation: Added Polish translation. Thank you Bartosz Arendt - Digital Factory - www.digitalfactory.pl
|
92 |
+
* Update : Added id attribute to all div.field (id="acf-$field_name")
|
93 |
+
|
94 |
= 3.1.6 =
|
95 |
* New style for buttons
|
96 |
* Bug Fix: Repeater maximum row setting was disabling the "add row" button 1 row early.
|