Skip to content

Commit 50ba132

Browse files
Fix multitaxonomy & multisite taxonomy compatibility with ACF v6.3.1 (#128)
1 parent 8e606d2 commit 50ba132

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/Fields/MultisiteTaxonomy.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ function get_ajax_query( $options = [] ) {
141141
/**
142142
* This function returns the value label for the input element on the admin side.
143143
*
144-
* @param \WP_Term $term The term object.
145-
* @param array $field The field settings.
146-
* @param int $post_id The post_id to which this value is saved to
144+
* @param \WP_Term $term The term object.
145+
* @param array $field The field settings.
146+
* @param int $post_id The post_id to which this value is saved to
147+
* @param boolean $unescape Should we return an unescaped post title.
147148
* @return string
148149
*/
149-
function get_term_title( $term, $field, $post_id = 0 ) {
150+
function get_term_title( $term, $field, $post_id = 0, $unescape = false ) {
150151

151152
// get post_id
152153
if ( ! $post_id ) {
@@ -168,6 +169,11 @@ function get_term_title( $term, $field, $post_id = 0 ) {
168169
// title
169170
$title .= $term->name;
170171

172+
// unescape for select2 output which handles the escaping.
173+
if ( $unescape ) {
174+
$title = html_entity_decode( $title );
175+
}
176+
171177
// filters
172178
$title = apply_filters( 'acf/fields/multisite_taxonomy/result', $title, $term, $field, $post_id );
173179
$title = apply_filters( 'acf/fields/multisite_taxonomy/result/name=' . $field['_name'], $title, $term, $field, $post_id );

src/Fields/Multitaxonomy.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@ function get_ajax_query( $options = [] ) {
133133
/**
134134
* This function returns the value label for the input element on the admin side.
135135
*
136-
* @param \WP_Term $term The term object.
137-
* @param array $field The field settings.
138-
* @param int $post_id The post_id to which this value is saved to
136+
* @param \WP_Term $term The term object.
137+
* @param array $field The field settings.
138+
* @param int $post_id The post_id to which this value is saved to
139+
* @param boolean $unescape Should we return an unescaped post title.
139140
* @return string
140141
*/
141-
function get_term_title( $term, $field, $post_id = 0 ) {
142+
function get_term_title( $term, $field, $post_id = 0, $unescape = false ) {
142143

143144
// get post_id
144145
if ( ! $post_id ) {
@@ -160,6 +161,11 @@ function get_term_title( $term, $field, $post_id = 0 ) {
160161
// title
161162
$title .= $term->name;
162163

164+
// unescape for select2 output which handles the escaping.
165+
if ( $unescape ) {
166+
$title = html_entity_decode( $title );
167+
}
168+
163169
// filters
164170
$title = apply_filters( 'acf/fields/taxonomy/result', $title, $term, $field, $post_id );
165171
$title = apply_filters( 'acf/fields/taxonomy/result/name=' . $field['_name'], $title, $term, $field, $post_id );
@@ -508,7 +514,7 @@ function start_el( &$output, $term, $depth = 0, $args = [], $current_object_id =
508514

509515
foreach ( $field['taxonomy'] as $taxonomy ) {
510516
// taxonomy
511-
$taxonomy_obj = get_taxonomy( $taxonomy );
517+
$taxonomy_obj = get_taxonomy( $taxonomy );
512518

513519
// vars
514520
$args = [

0 commit comments

Comments
 (0)