Version Description
- Field: Taxonomy Terms - Fixed a problem with value return when "Load Terms" was enabled
- General: Modal - Fixed z-index problem with WP attachment modal
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.8.4.6 |
Comparing to | |
See all releases |
Code changes from version 0.8.4.5 to 0.8.4.6
- acf-extended.php +2 -2
- assets/acf-extended-fc.css +1 -0
- assets/acf-extended-modal.css +18 -3
- includes/fields/field-taxonomy-terms.php +205 -205
- readme.txt +5 -1
acf-extended.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
-
* Version: 0.8.4.
|
6 |
* Author: ACF Extended
|
7 |
* Author URI: https://www.acf-extended.com
|
8 |
* Text Domain: acfe
|
@@ -16,7 +16,7 @@ if(!class_exists('ACFE')):
|
|
16 |
class ACFE{
|
17 |
|
18 |
// Version
|
19 |
-
var $version = '0.8.4.
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.8.4.6
|
6 |
* Author: ACF Extended
|
7 |
* Author URI: https://www.acf-extended.com
|
8 |
* Text Domain: acfe
|
16 |
class ACFE{
|
17 |
|
18 |
// Version
|
19 |
+
var $version = '0.8.4.6';
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
assets/acf-extended-fc.css
CHANGED
@@ -115,6 +115,7 @@
|
|
115 |
box-shadow:none;
|
116 |
background:#fff;
|
117 |
width: 30px;
|
|
|
118 |
height: 30px;
|
119 |
padding:0;
|
120 |
display:block;
|
115 |
box-shadow:none;
|
116 |
background:#fff;
|
117 |
width: 30px;
|
118 |
+
min-height: 30px;
|
119 |
height: 30px;
|
120 |
padding:0;
|
121 |
display:block;
|
assets/acf-extended-modal.css
CHANGED
@@ -17,7 +17,7 @@ body.acfe-modal-opened{
|
|
17 |
bottom:0;
|
18 |
height:100%;
|
19 |
width:100%;
|
20 |
-
z-index:
|
21 |
}
|
22 |
|
23 |
/*
|
@@ -32,7 +32,7 @@ body.acfe-modal-opened{
|
|
32 |
|
33 |
.acfe-modal.-open{
|
34 |
position:fixed;
|
35 |
-
z-index:
|
36 |
height:100%;
|
37 |
width:100%;
|
38 |
top:0;
|
@@ -500,7 +500,7 @@ body:not(.acf-admin-5-3) .acfe-modal.-open .acfe-modal-content .acfe-flex-contai
|
|
500 |
}
|
501 |
|
502 |
/*
|
503 |
-
* ACFE Modal Gutenberg Fix
|
504 |
*/
|
505 |
body.block-editor-page .edit-post-layout .acfe-modal.-open{
|
506 |
-webkit-box-pack: start;
|
@@ -560,4 +560,19 @@ body.block-editor-page.folded .edit-post-layout.is-sidebar-opened .acfe-modal.-o
|
|
560 |
|
561 |
body.block-editor-page .acfe-modal-overlay{
|
562 |
display:none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
17 |
bottom:0;
|
18 |
height:100%;
|
19 |
width:100%;
|
20 |
+
z-index:100000;
|
21 |
}
|
22 |
|
23 |
/*
|
32 |
|
33 |
.acfe-modal.-open{
|
34 |
position:fixed;
|
35 |
+
z-index:100001;
|
36 |
height:100%;
|
37 |
width:100%;
|
38 |
top:0;
|
500 |
}
|
501 |
|
502 |
/*
|
503 |
+
* ACFE Modal: Gutenberg Fix
|
504 |
*/
|
505 |
body.block-editor-page .edit-post-layout .acfe-modal.-open{
|
506 |
-webkit-box-pack: start;
|
560 |
|
561 |
body.block-editor-page .acfe-modal-overlay{
|
562 |
display:none;
|
563 |
+
}
|
564 |
+
|
565 |
+
/*
|
566 |
+
* ACFE Modal: Attachment Single Fix for Image Field
|
567 |
+
*/
|
568 |
+
body.wp-admin.upload-php.acfe-modal-opened > div:not([style*="display: none;"]) > .media-modal.wp-core-ui:not(.acf-media-modal):before{
|
569 |
+
content:"";
|
570 |
+
display:block;
|
571 |
+
position:absolute;
|
572 |
+
background:rgba(0,0,0,.7);
|
573 |
+
top:0;
|
574 |
+
left:0;
|
575 |
+
width:100%;
|
576 |
+
height:100%;
|
577 |
+
z-index:10000;
|
578 |
}
|
includes/fields/field-taxonomy-terms.php
CHANGED
@@ -8,7 +8,7 @@ if(!class_exists('acfe_field_taxonomy_terms')):
|
|
8 |
class acfe_field_taxonomy_terms extends acf_field{
|
9 |
|
10 |
// vars
|
11 |
-
|
12 |
|
13 |
function __construct(){
|
14 |
|
@@ -35,32 +35,32 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
35 |
);
|
36 |
|
37 |
// ajax
|
38 |
-
|
39 |
-
|
40 |
|
41 |
add_action('wp_ajax_acf/fields/acfe_taxonomy_terms/query', array($this, 'ajax_query'));
|
42 |
-
|
43 |
|
44 |
// actions
|
45 |
-
|
46 |
|
47 |
parent::__construct();
|
48 |
|
49 |
}
|
50 |
|
51 |
function ajax_query(){
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
die();
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
function get_ajax_query($options = array()){
|
66 |
|
@@ -69,30 +69,30 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
69 |
}
|
70 |
|
71 |
function ajax_query_allowed_terms(){
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
die();
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
'taxonomies' => array(),
|
94 |
'level' => false,
|
95 |
-
|
96 |
|
97 |
// get grouped terms
|
98 |
$args = array('taxonomy' => $options['taxonomies']);
|
@@ -123,9 +123,9 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
123 |
}
|
124 |
|
125 |
$groups = acf_get_choices_from_grouped_terms($terms, 'name');
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
|
130 |
// loop
|
131 |
foreach(array_keys($groups) as $group_title){
|
@@ -196,10 +196,10 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
196 |
'results' => $results
|
197 |
);
|
198 |
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
|
204 |
function get_available_terms($field){
|
205 |
|
@@ -372,17 +372,17 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
372 |
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
373 |
|
374 |
// Allow Taxonomy
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
|
387 |
// Allow Terms
|
388 |
$choices = array();
|
@@ -451,32 +451,32 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
451 |
|
452 |
}
|
453 |
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
'ajax' => 1,
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
|
468 |
// Select: Terms level
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
'_append' => 'allow_terms',
|
478 |
'value' => false
|
479 |
-
|
480 |
|
481 |
// field_type
|
482 |
acf_render_field_setting($field, array(
|
@@ -492,12 +492,12 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
492 |
));
|
493 |
|
494 |
// default_value
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
|
502 |
// return_format
|
503 |
acf_render_field_setting($field, array(
|
@@ -514,12 +514,12 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
514 |
));
|
515 |
|
516 |
// Select: ui
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
'conditions' => array(
|
524 |
array(
|
525 |
array(
|
@@ -529,15 +529,15 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
529 |
),
|
530 |
),
|
531 |
)
|
532 |
-
|
533 |
|
534 |
// Select: allow_null
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
'conditions' => array(
|
542 |
array(
|
543 |
array(
|
@@ -547,7 +547,7 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
547 |
),
|
548 |
),
|
549 |
)
|
550 |
-
|
551 |
|
552 |
// placeholder
|
553 |
acf_render_field_setting($field, array(
|
@@ -587,12 +587,12 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
587 |
));
|
588 |
|
589 |
// Select: multiple
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
'conditions' => array(
|
597 |
array(
|
598 |
array(
|
@@ -602,15 +602,15 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
602 |
),
|
603 |
),
|
604 |
)
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
'conditions' => array(
|
615 |
array(
|
616 |
array(
|
@@ -625,19 +625,19 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
625 |
),
|
626 |
),
|
627 |
)
|
628 |
-
|
629 |
|
630 |
// Checkbox: layout
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
'conditions' => array(
|
642 |
array(
|
643 |
array(
|
@@ -647,15 +647,15 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
647 |
),
|
648 |
),
|
649 |
)
|
650 |
-
|
651 |
|
652 |
// Checkbox: toggle
|
653 |
acf_render_field_setting( $field, array(
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
'conditions' => array(
|
660 |
array(
|
661 |
array(
|
@@ -665,73 +665,73 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
665 |
),
|
666 |
),
|
667 |
)
|
668 |
-
|
669 |
|
670 |
// save_terms
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
|
688 |
}
|
689 |
|
690 |
function load_value($value, $post_id, $field){
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
|
698 |
$taxonomy = $field['taxonomy'];
|
699 |
|
700 |
if(empty($taxonomy))
|
701 |
$taxonomy = acf_get_taxonomies();
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
return false;
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
|
736 |
function update_value($value, $post_id, $field){
|
737 |
|
@@ -796,29 +796,29 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
796 |
// return
|
797 |
return $value;
|
798 |
|
799 |
-
|
800 |
|
801 |
function save_post($post_id){
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
return;
|
806 |
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
|
823 |
function format_value($value, $post_id, $field){
|
824 |
|
@@ -826,7 +826,7 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
826 |
return $value;
|
827 |
|
828 |
// Return: object
|
829 |
-
|
830 |
|
831 |
// array
|
832 |
if(acf_is_array($value)){
|
@@ -864,10 +864,10 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
864 |
|
865 |
}
|
866 |
|
867 |
-
|
868 |
|
869 |
-
|
870 |
-
|
871 |
|
872 |
}
|
873 |
|
8 |
class acfe_field_taxonomy_terms extends acf_field{
|
9 |
|
10 |
// vars
|
11 |
+
var $save_post_terms = array();
|
12 |
|
13 |
function __construct(){
|
14 |
|
35 |
);
|
36 |
|
37 |
// ajax
|
38 |
+
add_action('wp_ajax_acfe/fields/taxonomy_terms/allow_query', array($this, 'ajax_query_allowed_terms'));
|
39 |
+
add_action('wp_ajax_nopriv_acfe/fields/taxonomy_terms/allow_query', array($this, 'ajax_query_allowed_terms'));
|
40 |
|
41 |
add_action('wp_ajax_acf/fields/acfe_taxonomy_terms/query', array($this, 'ajax_query'));
|
42 |
+
add_action('wp_ajax_nopriv_acf/fields/acfe_taxonomy_terms/query', array($this, 'ajax_query'));
|
43 |
|
44 |
// actions
|
45 |
+
add_action('acf/save_post', array($this, 'save_post'), 15, 1);
|
46 |
|
47 |
parent::__construct();
|
48 |
|
49 |
}
|
50 |
|
51 |
function ajax_query(){
|
52 |
+
|
53 |
+
// validate
|
54 |
+
if(!acf_verify_ajax())
|
55 |
die();
|
56 |
+
|
57 |
+
// get choices
|
58 |
+
$response = $this->get_ajax_query($_POST);
|
59 |
+
|
60 |
+
// return
|
61 |
+
acf_send_ajax_results($response);
|
62 |
+
|
63 |
+
}
|
64 |
|
65 |
function get_ajax_query($options = array()){
|
66 |
|
69 |
}
|
70 |
|
71 |
function ajax_query_allowed_terms(){
|
72 |
+
|
73 |
+
// validate
|
74 |
+
if(!acf_verify_ajax())
|
75 |
die();
|
76 |
+
|
77 |
+
// get choices
|
78 |
+
$response = $this->get_ajax_query_allowed_terms($_POST);
|
79 |
+
|
80 |
+
// return
|
81 |
+
acf_send_ajax_results($response);
|
82 |
+
|
83 |
+
}
|
84 |
|
85 |
+
function get_ajax_query_allowed_terms($options = array()){
|
86 |
+
|
87 |
+
// defaults
|
88 |
+
$options = acf_parse_args($options, array(
|
89 |
+
'post_id' => 0,
|
90 |
+
's' => '',
|
91 |
+
'field_key' => '',
|
92 |
+
'paged' => 1,
|
93 |
'taxonomies' => array(),
|
94 |
'level' => false,
|
95 |
+
));
|
96 |
|
97 |
// get grouped terms
|
98 |
$args = array('taxonomy' => $options['taxonomies']);
|
123 |
}
|
124 |
|
125 |
$groups = acf_get_choices_from_grouped_terms($terms, 'name');
|
126 |
+
|
127 |
+
// vars
|
128 |
+
$results = array();
|
129 |
|
130 |
// loop
|
131 |
foreach(array_keys($groups) as $group_title){
|
196 |
'results' => $results
|
197 |
);
|
198 |
|
199 |
+
// return
|
200 |
+
return $response;
|
201 |
+
|
202 |
+
}
|
203 |
|
204 |
function get_available_terms($field){
|
205 |
|
372 |
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
373 |
|
374 |
// Allow Taxonomy
|
375 |
+
acf_render_field_setting($field, array(
|
376 |
+
'label' => __('Allow Taxonomy','acf'),
|
377 |
+
'instructions' => '',
|
378 |
+
'type' => 'select',
|
379 |
+
'name' => 'taxonomy',
|
380 |
+
'choices' => acf_get_taxonomy_labels(),
|
381 |
+
'multiple' => 1,
|
382 |
+
'ui' => 1,
|
383 |
+
'allow_null' => 1,
|
384 |
+
'placeholder' => __("All taxonomies",'acf'),
|
385 |
+
));
|
386 |
|
387 |
// Allow Terms
|
388 |
$choices = array();
|
451 |
|
452 |
}
|
453 |
|
454 |
+
acf_render_field_setting($field, array(
|
455 |
+
'label' => __('Allow Terms','acf'),
|
456 |
+
'instructions' => '',
|
457 |
+
'type' => 'select',
|
458 |
+
'name' => 'allow_terms',
|
459 |
+
'choices' => $choices,
|
460 |
+
'multiple' => 1,
|
461 |
+
'ui' => 1,
|
462 |
+
'allow_null' => 1,
|
463 |
'ajax' => 1,
|
464 |
+
'placeholder' => __("All terms",'acf'),
|
465 |
+
'ajax_action' => 'acfe/fields/taxonomy_terms/allow_query',
|
466 |
+
));
|
467 |
|
468 |
// Select: Terms level
|
469 |
+
acf_render_field_setting($field, array(
|
470 |
+
'label' => __('Terms_level','acf'),
|
471 |
+
'instructions' => '',
|
472 |
+
'name' => 'allow_level',
|
473 |
+
'type' => 'number',
|
474 |
+
'append' => 'levels',
|
475 |
+
'min' => 0,
|
476 |
+
'placeholder' => __('All','acf'),
|
477 |
'_append' => 'allow_terms',
|
478 |
'value' => false
|
479 |
+
));
|
480 |
|
481 |
// field_type
|
482 |
acf_render_field_setting($field, array(
|
492 |
));
|
493 |
|
494 |
// default_value
|
495 |
+
acf_render_field_setting($field, array(
|
496 |
+
'label' => __('Default Value','acf'),
|
497 |
+
'instructions' => __('Enter each default value on a new line','acf'),
|
498 |
+
'name' => 'default_value',
|
499 |
+
'type' => 'textarea',
|
500 |
+
));
|
501 |
|
502 |
// return_format
|
503 |
acf_render_field_setting($field, array(
|
514 |
));
|
515 |
|
516 |
// Select: ui
|
517 |
+
acf_render_field_setting( $field, array(
|
518 |
+
'label' => __('Stylised UI','acf'),
|
519 |
+
'instructions' => '',
|
520 |
+
'name' => 'ui',
|
521 |
+
'type' => 'true_false',
|
522 |
+
'ui' => 1,
|
523 |
'conditions' => array(
|
524 |
array(
|
525 |
array(
|
529 |
),
|
530 |
),
|
531 |
)
|
532 |
+
));
|
533 |
|
534 |
// Select: allow_null
|
535 |
+
acf_render_field_setting($field, array(
|
536 |
+
'label' => __('Allow Null?','acf'),
|
537 |
+
'instructions' => '',
|
538 |
+
'name' => 'allow_null',
|
539 |
+
'type' => 'true_false',
|
540 |
+
'ui' => 1,
|
541 |
'conditions' => array(
|
542 |
array(
|
543 |
array(
|
547 |
),
|
548 |
),
|
549 |
)
|
550 |
+
));
|
551 |
|
552 |
// placeholder
|
553 |
acf_render_field_setting($field, array(
|
587 |
));
|
588 |
|
589 |
// Select: multiple
|
590 |
+
acf_render_field_setting( $field, array(
|
591 |
+
'label' => __('Select multiple values?','acf'),
|
592 |
+
'instructions' => '',
|
593 |
+
'name' => 'multiple',
|
594 |
+
'type' => 'true_false',
|
595 |
+
'ui' => 1,
|
596 |
'conditions' => array(
|
597 |
array(
|
598 |
array(
|
602 |
),
|
603 |
),
|
604 |
)
|
605 |
+
));
|
606 |
+
|
607 |
+
// Select: ajax
|
608 |
+
acf_render_field_setting( $field, array(
|
609 |
+
'label' => __('Use AJAX to lazy load choices?','acf'),
|
610 |
+
'instructions' => '',
|
611 |
+
'name' => 'ajax',
|
612 |
+
'type' => 'true_false',
|
613 |
+
'ui' => 1,
|
614 |
'conditions' => array(
|
615 |
array(
|
616 |
array(
|
625 |
),
|
626 |
),
|
627 |
)
|
628 |
+
));
|
629 |
|
630 |
// Checkbox: layout
|
631 |
+
acf_render_field_setting( $field, array(
|
632 |
+
'label' => __('Layout','acf'),
|
633 |
+
'instructions' => '',
|
634 |
+
'type' => 'radio',
|
635 |
+
'name' => 'layout',
|
636 |
+
'layout' => 'horizontal',
|
637 |
+
'choices' => array(
|
638 |
+
'vertical' => __("Vertical",'acf'),
|
639 |
+
'horizontal' => __("Horizontal",'acf')
|
640 |
+
),
|
641 |
'conditions' => array(
|
642 |
array(
|
643 |
array(
|
647 |
),
|
648 |
),
|
649 |
)
|
650 |
+
));
|
651 |
|
652 |
// Checkbox: toggle
|
653 |
acf_render_field_setting( $field, array(
|
654 |
+
'label' => __('Toggle','acf'),
|
655 |
+
'instructions' => __('Prepend an extra checkbox to toggle all choices','acf'),
|
656 |
+
'name' => 'toggle',
|
657 |
+
'type' => 'true_false',
|
658 |
+
'ui' => 1,
|
659 |
'conditions' => array(
|
660 |
array(
|
661 |
array(
|
665 |
),
|
666 |
),
|
667 |
)
|
668 |
+
));
|
669 |
|
670 |
// save_terms
|
671 |
+
acf_render_field_setting( $field, array(
|
672 |
+
'label' => __('Save Terms','acf'),
|
673 |
+
'instructions' => __('Connect selected terms to the post','acf'),
|
674 |
+
'name' => 'save_terms',
|
675 |
+
'type' => 'true_false',
|
676 |
+
'ui' => 1,
|
677 |
+
));
|
678 |
+
|
679 |
+
// load_terms
|
680 |
+
acf_render_field_setting( $field, array(
|
681 |
+
'label' => __('Load Terms','acf'),
|
682 |
+
'instructions' => __('Load value from posts terms','acf'),
|
683 |
+
'name' => 'load_terms',
|
684 |
+
'type' => 'true_false',
|
685 |
+
'ui' => 1,
|
686 |
+
));
|
687 |
|
688 |
}
|
689 |
|
690 |
function load_value($value, $post_id, $field){
|
691 |
+
|
692 |
+
// load_terms
|
693 |
+
if($field['load_terms']){
|
694 |
+
|
695 |
+
// get valid terms
|
696 |
+
$value = acf_get_array($value);
|
697 |
|
698 |
$taxonomy = $field['taxonomy'];
|
699 |
|
700 |
if(empty($taxonomy))
|
701 |
$taxonomy = acf_get_taxonomies();
|
702 |
+
|
703 |
+
// get terms
|
704 |
+
$info = acf_get_post_id_info($post_id);
|
705 |
+
$term_ids = wp_get_object_terms($info['id'], $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
|
706 |
+
|
707 |
+
// bail early if no terms
|
708 |
+
if(empty($term_ids) || is_wp_error($term_ids))
|
709 |
return false;
|
710 |
+
|
711 |
+
// sort
|
712 |
+
if(!empty($value)){
|
713 |
+
|
714 |
+
$order = array();
|
715 |
+
|
716 |
+
foreach($term_ids as $i => $v){
|
717 |
+
|
718 |
+
$order[$i] = array_search($v, $value);
|
719 |
+
|
720 |
+
}
|
721 |
+
|
722 |
+
array_multisort($order, $term_ids);
|
723 |
+
|
724 |
+
}
|
725 |
+
|
726 |
+
// update value
|
727 |
+
$value = $term_ids;
|
728 |
+
|
729 |
+
}
|
730 |
+
|
731 |
+
// return
|
732 |
+
return $value;
|
733 |
+
|
734 |
+
}
|
735 |
|
736 |
function update_value($value, $post_id, $field){
|
737 |
|
796 |
// return
|
797 |
return $value;
|
798 |
|
799 |
+
}
|
800 |
|
801 |
function save_post($post_id){
|
802 |
+
|
803 |
+
// bail ealry if no terms
|
804 |
+
if(empty($this->save_post_terms))
|
805 |
return;
|
806 |
|
807 |
+
// vars
|
808 |
+
$info = acf_get_post_id_info($post_id);
|
809 |
+
|
810 |
+
// loop
|
811 |
+
foreach($this->save_post_terms as $taxonomy => $term_ids){
|
812 |
+
|
813 |
+
// save
|
814 |
+
wp_set_object_terms($info['id'], $term_ids, $taxonomy, false);
|
815 |
+
|
816 |
+
}
|
817 |
+
|
818 |
+
// reset array ( WP saves twice )
|
819 |
+
$this->save_post_terms = array();
|
820 |
+
|
821 |
+
}
|
822 |
|
823 |
function format_value($value, $post_id, $field){
|
824 |
|
826 |
return $value;
|
827 |
|
828 |
// Return: object
|
829 |
+
if($field['return_format'] === 'object' || $field['return_format'] === 'name'){
|
830 |
|
831 |
// array
|
832 |
if(acf_is_array($value)){
|
864 |
|
865 |
}
|
866 |
|
867 |
+
}
|
868 |
|
869 |
+
// return
|
870 |
+
return $value;
|
871 |
|
872 |
}
|
873 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: acf, custom fields, meta, admin, fields, form, repeater, content
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 0.8.4.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -683,6 +683,10 @@ function my_acfe_modules(){
|
|
683 |
|
684 |
== Changelog ==
|
685 |
|
|
|
|
|
|
|
|
|
686 |
= 0.8.4.5 =
|
687 |
* Field Group: Hide on Screen - Added "Block Editor" (Gutenberg) setting, allowing administrator to disable the block editor on field group location
|
688 |
* Field Group: Third Party - Fixed Export/Sync Clones fields being processed during the action
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 0.8.4.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
683 |
|
684 |
== Changelog ==
|
685 |
|
686 |
+
= 0.8.4.6 =
|
687 |
+
* Field: Taxonomy Terms - Fixed a problem with value return when "Load Terms" was enabled
|
688 |
+
* General: Modal - Fixed z-index problem with WP attachment modal
|
689 |
+
|
690 |
= 0.8.4.5 =
|
691 |
* Field Group: Hide on Screen - Added "Block Editor" (Gutenberg) setting, allowing administrator to disable the block editor on field group location
|
692 |
* Field Group: Third Party - Fixed Export/Sync Clones fields being processed during the action
|