Skip to content

Commit b5af43a

Browse files
authored
Fix incompatibilities with ACF 6.3.10 (#131)
1 parent a2eb7ef commit b5af43a

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
[Unreleased]
88

9+
## [1.41.3]
10+
11+
### Fixed
12+
- Fix MultisiteTaxonomy and Multitaxonomy compatibility with ACF v6.3.10.
13+
914
## [1.41.2]
1015

1116
### Fixed

plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: ACF Codifier
44
Plugin URI: https://github.com/devgeniem/acf-codifier
55
Description: A helper class to make defining ACF field groups and fields easier in the code.
6-
Version: 1.41.2
6+
Version: 1.41.3
77
Author: Miika Arponen / Geniem Oy
88
Author URI: https://geniem.fi
99
License: GPL-3.0

src/Fields/MultisiteTaxonomy.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Geniem\ACF\Fields;
77

8-
add_action( 'acf/init', function() {
8+
add_action( 'acf/init', function () {
99
/**
1010
* ACF MultisiteTaxonomy Relationship class
1111
*/
@@ -79,7 +79,6 @@ function get_ajax_query( $options = [] ) {
7979
]
8080
);
8181

82-
8382
// bail early if a taxonomy does not exist
8483
$taxonomies_exist = $this->taxonomies_exist( $field['taxonomy'] );
8584

@@ -201,7 +200,7 @@ protected function get_all_terms( $args ) {
201200
] );
202201

203202
// parameters changed in version 4.5
204-
if( acf_version_compare( 'wp', '<', '4.5' ) ) {
203+
if ( acf_version_compare( 'wp', '<', '4.5' ) ) {
205204
return get_terms( $args['taxonomy'], $args );
206205
}
207206

@@ -307,12 +306,15 @@ public function render_field( $field ) {
307306
// force value to array
308307
$field['value'] = acf_get_array( $field['value'] );
309308

309+
$nonce = wp_create_nonce( 'acf_field_' . $this->name . '_' . $field['key'] );
310+
310311
// vars
311312
$div = [
312313
'class' => 'acf-multisite-taxonomy-field',
313314
'data-ftype' => $field['field_type'],
314315
'data-taxonomy' => $field['taxonomy'],
315316
'data-allow_null' => $field['allow_null'],
317+
'data-nonce' => $nonce,
316318
];
317319

318320
// get taxonomy
@@ -331,13 +333,13 @@ public function render_field( $field ) {
331333

332334
$field['multiple'] = 0;
333335

334-
$this->render_field_select( $field );
336+
$this->render_field_select( $field, $nonce );
335337

336338
} elseif ( $field['field_type'] == 'multi_select' ) {
337339

338340
$field['multiple'] = 1;
339341

340-
$this->render_field_select( $field );
342+
$this->render_field_select( $field, $nonce );
341343

342344
} elseif ( $field['field_type'] == 'radio' ) {
343345

src/Fields/Multitaxonomy.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,16 @@ public function render_field( $field ) {
381381
// force value to array
382382
$field['value'] = acf_get_array( $field['value'] );
383383

384+
$nonce = wp_create_nonce( 'acf_field_' . $this->name . '_' . $field['key'] );
385+
384386
// vars
385387
$div = [
386388
'class' => 'acf-multitaxonomy-field',
387389
'data-save' => $field['save_terms'],
388390
'data-ftype' => $field['field_type'],
389391
'data-taxonomy' => $field['taxonomy'],
390392
'data-allow_null' => $field['allow_null'],
393+
'data-nonce' => $nonce,
391394
];
392395

393396
// get taxonomy
@@ -406,13 +409,13 @@ public function render_field( $field ) {
406409

407410
$field['multiple'] = 0;
408411

409-
$this->render_field_select( $field );
412+
$this->render_field_select( $field, $nonce );
410413

411414
} elseif ( $field['field_type'] == 'multi_select' ) {
412415

413416
$field['multiple'] = 1;
414417

415-
$this->render_field_select( $field );
418+
$this->render_field_select( $field, $nonce );
416419

417420
} elseif ( $field['field_type'] == 'radio' ) {
418421

@@ -430,17 +433,19 @@ public function render_field( $field ) {
430433
}
431434

432435
/**
433-
* Render field select
436+
* Render field select.
434437
*
435438
* @param array $field The field object.
439+
* @param string $nonce The nonce.
436440
* @return void
437441
*/
438-
public function render_field_select( $field ) {
442+
public function render_field_select( $field, $nonce ) {
439443

440444
// Change Field into a select
441445
$field['type'] = 'select';
442446
$field['ui'] = 1;
443447
$field['ajax'] = 1;
448+
$field['nonce'] = $nonce;
444449
$field['choices'] = [];
445450
$field['disabled'] = $field['disable'] ?? false;
446451

0 commit comments

Comments
 (0)