Version Description
- [Fixed] Fix PHP registered field groups not showing via AJAX - http://support.advancedcustomfields.com/discussion/3143/exported-php-code-doesnt-work-with-post-formats
- [Added] Add new return value for file { file object
- [Fixed] Test / Fix save_post priority with WPML + events + shopp plugin
- [Fixed] Fix bug where field groups don't appear on shopp product edit screens
- [Fixed] Fix bug with image field { selecting multiple images puts first image into the .row-clone tr - http://support.advancedcustomfields.com/discussion/3157/image-field-repeater
Download this release
Release Info
Developer | elliotcondon |
Plugin | Advanced Custom Fields |
Version | 3.4.3 |
Comparing to | |
See all releases |
Code changes from version 3.4.2 to 3.4.3
- acf.php +53 -26
- core/controllers/input.php +11 -2
- core/fields/checkbox.php +14 -2
- core/fields/file.php +40 -8
- core/fields/image.php +1 -1
- core/fields/select.php +18 -2
- css/acf.css +0 -0
- css/input.css +2 -1
- readme.txt +8 -1
acf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
|
6 |
-
Version: 3.4.
|
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.4.
|
51 |
$this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
|
52 |
$this->cache = array(); // basic array cache to hold data throughout the page load
|
53 |
|
@@ -67,7 +67,7 @@ class Acf
|
|
67 |
|
68 |
add_action('admin_menu', array($this,'admin_menu'));
|
69 |
add_action('admin_head', array($this,'admin_head'));
|
70 |
-
add_action('acf_save_post', array($this, 'acf_save_post'),
|
71 |
|
72 |
|
73 |
// ajax
|
@@ -490,6 +490,29 @@ class Acf
|
|
490 |
|
491 |
function get_acf_fields($post_id)
|
492 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
// vars
|
494 |
$return = array();
|
495 |
$keys = get_post_custom_keys($post_id);
|
@@ -528,8 +551,8 @@ class Acf
|
|
528 |
{
|
529 |
// vars
|
530 |
$post_id = $post_id ? $post_id : $this->get_post_meta_post_id($field_name);
|
531 |
-
$field = false;
|
532 |
|
|
|
533 |
// if this acf ($post_id) is trashed don't use it's fields
|
534 |
if(get_post_status($post_id) != "trash")
|
535 |
{
|
@@ -538,38 +561,42 @@ class Acf
|
|
538 |
|
539 |
// if field group was duplicated, it may now be a serialized string!
|
540 |
$field = maybe_unserialize($field);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
}
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
|
|
549 |
{
|
550 |
-
// loop through
|
551 |
-
|
552 |
{
|
553 |
-
|
554 |
-
if($acf['fields'])
|
555 |
{
|
556 |
-
|
557 |
{
|
558 |
-
|
559 |
-
{
|
560 |
-
return $field;
|
561 |
-
}
|
562 |
}
|
563 |
}
|
564 |
-
// if($acf['fields'])
|
565 |
}
|
566 |
-
//
|
567 |
}
|
568 |
-
//
|
569 |
-
|
570 |
-
|
|
|
571 |
|
572 |
-
return
|
573 |
|
574 |
}
|
575 |
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
|
6 |
+
Version: 3.4.3
|
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.4.3';
|
51 |
$this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
|
52 |
$this->cache = array(); // basic array cache to hold data throughout the page load
|
53 |
|
67 |
|
68 |
add_action('admin_menu', array($this,'admin_menu'));
|
69 |
add_action('admin_head', array($this,'admin_head'));
|
70 |
+
add_action('acf_save_post', array($this, 'acf_save_post'), 10); // save post, called from many places (api, input, everything, options)
|
71 |
|
72 |
|
73 |
// ajax
|
490 |
|
491 |
function get_acf_fields($post_id)
|
492 |
{
|
493 |
+
// registered or db
|
494 |
+
if( ! is_numeric($post_id) )
|
495 |
+
{
|
496 |
+
$acfs = apply_filters('acf_register_field_group', array());
|
497 |
+
|
498 |
+
if($acfs)
|
499 |
+
{
|
500 |
+
// loop through acfs
|
501 |
+
foreach($acfs as $acf)
|
502 |
+
{
|
503 |
+
if( $acf['id'] != $post_id)
|
504 |
+
{
|
505 |
+
continue;
|
506 |
+
}
|
507 |
+
|
508 |
+
return $acf['fields'];
|
509 |
+
}
|
510 |
+
// foreach($acfs as $acf)
|
511 |
+
}
|
512 |
+
// if($acfs)
|
513 |
+
}
|
514 |
+
|
515 |
+
|
516 |
// vars
|
517 |
$return = array();
|
518 |
$keys = get_post_custom_keys($post_id);
|
551 |
{
|
552 |
// vars
|
553 |
$post_id = $post_id ? $post_id : $this->get_post_meta_post_id($field_name);
|
|
|
554 |
|
555 |
+
|
556 |
// if this acf ($post_id) is trashed don't use it's fields
|
557 |
if(get_post_status($post_id) != "trash")
|
558 |
{
|
561 |
|
562 |
// if field group was duplicated, it may now be a serialized string!
|
563 |
$field = maybe_unserialize($field);
|
564 |
+
|
565 |
+
|
566 |
+
if( $field )
|
567 |
+
{
|
568 |
+
return $field;
|
569 |
+
}
|
570 |
+
|
571 |
}
|
572 |
+
|
573 |
+
|
574 |
+
// hook to load in registered field groups
|
575 |
+
$acfs = apply_filters('acf_register_field_group', array());
|
576 |
+
if($acfs)
|
577 |
+
{
|
578 |
+
// loop through acfs
|
579 |
+
foreach($acfs as $acf)
|
580 |
{
|
581 |
+
// loop through fields
|
582 |
+
if($acf['fields'])
|
583 |
{
|
584 |
+
foreach($acf['fields'] as $field)
|
|
|
585 |
{
|
586 |
+
if($field['key'] == $field_name)
|
587 |
{
|
588 |
+
return $field;
|
|
|
|
|
|
|
589 |
}
|
590 |
}
|
|
|
591 |
}
|
592 |
+
// if($acf['fields'])
|
593 |
}
|
594 |
+
// foreach($acfs as $acf)
|
595 |
+
}
|
596 |
+
// if($acfs)
|
597 |
+
|
598 |
|
599 |
+
return null;
|
600 |
|
601 |
}
|
602 |
|
core/controllers/input.php
CHANGED
@@ -35,7 +35,16 @@ class acf_input
|
|
35 |
add_action('admin_print_scripts', array($this,'admin_print_scripts'));
|
36 |
add_action('admin_print_styles', array($this,'admin_print_styles'));
|
37 |
add_action('admin_head', array($this,'admin_head'));
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
// custom actions (added in 3.1.8)
|
@@ -153,7 +162,7 @@ class acf_input
|
|
153 |
|
154 |
|
155 |
// shopp
|
156 |
-
if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] )
|
157 |
{
|
158 |
$typenow = "shopp_product";
|
159 |
}
|
35 |
add_action('admin_print_scripts', array($this,'admin_print_scripts'));
|
36 |
add_action('admin_print_styles', array($this,'admin_print_styles'));
|
37 |
add_action('admin_head', array($this,'admin_head'));
|
38 |
+
|
39 |
+
|
40 |
+
// save
|
41 |
+
$save_priority = 20;
|
42 |
+
|
43 |
+
if( isset($_POST['post_type']) )
|
44 |
+
{
|
45 |
+
if( $_POST['post_type'] == "tribe_events" ){ $save_priority = 15; }
|
46 |
+
}
|
47 |
+
add_action('save_post', array($this, 'save_post'), $save_priority); // save later to avoid issues with 3rd party plugins
|
48 |
|
49 |
|
50 |
// custom actions (added in 3.1.8)
|
162 |
|
163 |
|
164 |
// shopp
|
165 |
+
if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) )
|
166 |
{
|
167 |
$typenow = "shopp_product";
|
168 |
}
|
core/fields/checkbox.php
CHANGED
@@ -140,9 +140,21 @@ class acf_Checkbox extends acf_Field
|
|
140 |
|
141 |
function pre_save_field($field)
|
142 |
{
|
143 |
-
//
|
144 |
-
$
|
|
|
|
|
|
|
|
|
|
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
// vars
|
147 |
$new_choices = array();
|
148 |
|
140 |
|
141 |
function pre_save_field($field)
|
142 |
{
|
143 |
+
// vars
|
144 |
+
$defaults = array(
|
145 |
+
'choices' => '',
|
146 |
+
);
|
147 |
+
|
148 |
+
$field = array_merge($defaults, $field);
|
149 |
+
|
150 |
|
151 |
+
// check if is array. Normal back end edit posts a textarea, but a user might use update_field from the front end
|
152 |
+
if( is_array( $field['choices'] ))
|
153 |
+
{
|
154 |
+
return $field;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
// vars
|
159 |
$new_choices = array();
|
160 |
|
core/fields/file.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
class acf_File extends acf_Field
|
4 |
{
|
|
|
5 |
/*--------------------------------------------------------------------------------------
|
6 |
*
|
7 |
* Constructor
|
@@ -20,8 +21,8 @@ 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_action('wp_ajax_acf_select_file', array($this, 'ajax_select_file'));
|
24 |
add_filter('get_media_item_args', array($this, 'allow_file_insertion'));
|
|
|
25 |
add_action('acf_head-update_attachment-file', array($this, 'acf_head_update_attachment'));
|
26 |
}
|
27 |
|
@@ -216,8 +217,12 @@ class acf_File extends acf_Field
|
|
216 |
function create_options($key, $field)
|
217 |
{
|
218 |
// vars
|
219 |
-
$
|
|
|
|
|
220 |
|
|
|
|
|
221 |
?>
|
222 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
223 |
<td class="label">
|
@@ -231,14 +236,14 @@ class acf_File extends acf_Field
|
|
231 |
'value' => $field['save_format'],
|
232 |
'layout' => 'horizontal',
|
233 |
'choices' => array(
|
234 |
-
'
|
235 |
-
'
|
|
|
236 |
)
|
237 |
));
|
238 |
?>
|
239 |
</td>
|
240 |
</tr>
|
241 |
-
|
242 |
<?php
|
243 |
}
|
244 |
|
@@ -432,7 +437,7 @@ class acf_File extends acf_Field
|
|
432 |
self.parent.acf_div.closest('.repeater').find('.add-row-end').trigger('click');
|
433 |
|
434 |
// set acf_div to new row file
|
435 |
-
self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr:last
|
436 |
}
|
437 |
else
|
438 |
{
|
@@ -574,14 +579,41 @@ class acf_File extends acf_Field
|
|
574 |
function get_value_for_api($post_id, $field)
|
575 |
{
|
576 |
// vars
|
577 |
-
$
|
|
|
|
|
|
|
|
|
578 |
|
579 |
$value = parent::get_value($post_id, $field);
|
580 |
|
581 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
{
|
583 |
$value = wp_get_attachment_url($value);
|
584 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
|
586 |
return $value;
|
587 |
}
|
2 |
|
3 |
class acf_File extends acf_Field
|
4 |
{
|
5 |
+
|
6 |
/*--------------------------------------------------------------------------------------
|
7 |
*
|
8 |
* Constructor
|
21 |
$this->title = __('File','acf');
|
22 |
|
23 |
add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
|
|
|
24 |
add_filter('get_media_item_args', array($this, 'allow_file_insertion'));
|
25 |
+
add_action('wp_ajax_acf_select_file', array($this, 'ajax_select_file'));
|
26 |
add_action('acf_head-update_attachment-file', array($this, 'acf_head_update_attachment'));
|
27 |
}
|
28 |
|
217 |
function create_options($key, $field)
|
218 |
{
|
219 |
// vars
|
220 |
+
$defaults = array(
|
221 |
+
'save_format' => 'object',
|
222 |
+
);
|
223 |
|
224 |
+
$field = array_merge($defaults, $field);
|
225 |
+
|
226 |
?>
|
227 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
228 |
<td class="label">
|
236 |
'value' => $field['save_format'],
|
237 |
'layout' => 'horizontal',
|
238 |
'choices' => array(
|
239 |
+
'object' => __("File Object",'acf'),
|
240 |
+
'url' => __("File URL",'acf'),
|
241 |
+
'id' => __("File ID",'acf')
|
242 |
)
|
243 |
));
|
244 |
?>
|
245 |
</td>
|
246 |
</tr>
|
|
|
247 |
<?php
|
248 |
}
|
249 |
|
437 |
self.parent.acf_div.closest('.repeater').find('.add-row-end').trigger('click');
|
438 |
|
439 |
// set acf_div to new row file
|
440 |
+
self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr.row:last .acf-file-uploader');
|
441 |
}
|
442 |
else
|
443 |
{
|
579 |
function get_value_for_api($post_id, $field)
|
580 |
{
|
581 |
// vars
|
582 |
+
$defaults = array(
|
583 |
+
'save_format' => 'object',
|
584 |
+
);
|
585 |
+
|
586 |
+
$field = array_merge($defaults, $field);
|
587 |
|
588 |
$value = parent::get_value($post_id, $field);
|
589 |
|
590 |
+
|
591 |
+
// validate
|
592 |
+
if( !$value )
|
593 |
+
{
|
594 |
+
return false;
|
595 |
+
}
|
596 |
+
|
597 |
+
|
598 |
+
// format
|
599 |
+
if( $field['save_format'] == 'url' )
|
600 |
{
|
601 |
$value = wp_get_attachment_url($value);
|
602 |
}
|
603 |
+
elseif( $field['save_format'] == 'object' )
|
604 |
+
{
|
605 |
+
$attachment = get_post( $value );
|
606 |
+
|
607 |
+
// create array to hold value data
|
608 |
+
$value = array(
|
609 |
+
'id' => $attachment->ID,
|
610 |
+
'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
|
611 |
+
'title' => $attachment->post_title,
|
612 |
+
'caption' => $attachment->post_excerpt,
|
613 |
+
'description' => $attachment->post_content,
|
614 |
+
'url' => wp_get_attachment_url( $attachment->ID ),
|
615 |
+
);
|
616 |
+
}
|
617 |
|
618 |
return $value;
|
619 |
}
|
core/fields/image.php
CHANGED
@@ -473,7 +473,7 @@ class acf_Image extends acf_Field
|
|
473 |
self.parent.acf_div.closest('.repeater').find('.add-row-end').trigger('click');
|
474 |
|
475 |
// set acf_div to new row image
|
476 |
-
self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr:last
|
477 |
}
|
478 |
else
|
479 |
{
|
473 |
self.parent.acf_div.closest('.repeater').find('.add-row-end').trigger('click');
|
474 |
|
475 |
// set acf_div to new row image
|
476 |
+
self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr.row:last .acf-image-uploader');
|
477 |
}
|
478 |
else
|
479 |
{
|
core/fields/select.php
CHANGED
@@ -254,12 +254,25 @@ class acf_Select extends acf_Field
|
|
254 |
|
255 |
function pre_save_field($field)
|
256 |
{
|
257 |
-
//
|
258 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
260 |
// vars
|
261 |
$new_choices = array();
|
262 |
|
|
|
263 |
// explode choices from each line
|
264 |
if(strpos($field['choices'], "\n") !== false)
|
265 |
{
|
@@ -272,6 +285,7 @@ class acf_Select extends acf_Field
|
|
272 |
$field['choices'] = array($field['choices']);
|
273 |
}
|
274 |
|
|
|
275 |
// key => value
|
276 |
foreach($field['choices'] as $choice)
|
277 |
{
|
@@ -286,9 +300,11 @@ class acf_Select extends acf_Field
|
|
286 |
}
|
287 |
}
|
288 |
|
|
|
289 |
// update choices
|
290 |
$field['choices'] = $new_choices;
|
291 |
|
|
|
292 |
// return updated field
|
293 |
return $field;
|
294 |
|
254 |
|
255 |
function pre_save_field($field)
|
256 |
{
|
257 |
+
// vars
|
258 |
+
$defaults = array(
|
259 |
+
'choices' => '',
|
260 |
+
);
|
261 |
+
|
262 |
+
$field = array_merge($defaults, $field);
|
263 |
+
|
264 |
+
|
265 |
+
// check if is array. Normal back end edit posts a textarea, but a user might use update_field from the front end
|
266 |
+
if( is_array( $field['choices'] ))
|
267 |
+
{
|
268 |
+
return $field;
|
269 |
+
}
|
270 |
+
|
271 |
|
272 |
// vars
|
273 |
$new_choices = array();
|
274 |
|
275 |
+
|
276 |
// explode choices from each line
|
277 |
if(strpos($field['choices'], "\n") !== false)
|
278 |
{
|
285 |
$field['choices'] = array($field['choices']);
|
286 |
}
|
287 |
|
288 |
+
|
289 |
// key => value
|
290 |
foreach($field['choices'] as $choice)
|
291 |
{
|
300 |
}
|
301 |
}
|
302 |
|
303 |
+
|
304 |
// update choices
|
305 |
$field['choices'] = $new_choices;
|
306 |
|
307 |
+
|
308 |
// return updated field
|
309 |
return $field;
|
310 |
|
css/acf.css
CHANGED
Binary file
|
css/input.css
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
#poststuff .acf_postbox .widefat th,
|
6 |
#poststuff .acf_postbox .widefat td {
|
7 |
overflow: visible;
|
|
|
8 |
}
|
9 |
|
10 |
#poststuff .acf_postbox .inside {
|
@@ -365,7 +366,7 @@
|
|
365 |
}
|
366 |
|
367 |
.repeater > table > thead > tr > th {
|
368 |
-
|
369 |
border-right: 1px solid #e1e1e1;
|
370 |
}
|
371 |
|
5 |
#poststuff .acf_postbox .widefat th,
|
6 |
#poststuff .acf_postbox .widefat td {
|
7 |
overflow: visible;
|
8 |
+
|
9 |
}
|
10 |
|
11 |
#poststuff .acf_postbox .inside {
|
366 |
}
|
367 |
|
368 |
.repeater > table > thead > tr > th {
|
369 |
+
vertical-align: top;
|
370 |
border-right: 1px solid #e1e1e1;
|
371 |
}
|
372 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Elliot Condon
|
|
3 |
Tags: custom, field, custom field, advanced, simple fields, magic fields, more fields, repeater, matrix, post, type, text, textarea, file, image, edit, admin
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.4.2
|
6 |
-
Stable tag: 3.4.
|
7 |
|
8 |
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!
|
9 |
|
@@ -85,6 +85,13 @@ http://support.advancedcustomfields.com/
|
|
85 |
|
86 |
== Changelog ==
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
= 3.4.2 =
|
89 |
* [Fixed] Fix API functions for 'user_$ID' post ID parameter
|
90 |
* [Added] Color Picker Field: Default Value
|
3 |
Tags: custom, field, custom field, advanced, simple fields, magic fields, more fields, repeater, matrix, post, type, text, textarea, file, image, edit, admin
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.4.2
|
6 |
+
Stable tag: 3.4.3
|
7 |
|
8 |
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!
|
9 |
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
= 3.4.3 =
|
89 |
+
* [Fixed] Fix PHP registered field groups not showing via AJAX - http://support.advancedcustomfields.com/discussion/3143/exported-php-code-doesnt-work-with-post-formats
|
90 |
+
* [Added] Add new return value for file { file object
|
91 |
+
* [Fixed] Test / Fix save_post priority with WPML + events + shopp plugin
|
92 |
+
* [Fixed] Fix bug where field groups don't appear on shopp product edit screens
|
93 |
+
* [Fixed] Fix bug with image field { selecting multiple images puts first image into the .row-clone tr - http://support.advancedcustomfields.com/discussion/3157/image-field-repeater
|
94 |
+
|
95 |
= 3.4.2 =
|
96 |
* [Fixed] Fix API functions for 'user_$ID' post ID parameter
|
97 |
* [Added] Color Picker Field: Default Value
|