Skip to content

Commit

Permalink
Fix incompatibilities with ACF 6.3.10 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
HPiirainen authored Nov 4, 2024
1 parent a2eb7ef commit b5af43a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

[Unreleased]

## [1.41.3]

### Fixed
- Fix MultisiteTaxonomy and Multitaxonomy compatibility with ACF v6.3.10.

## [1.41.2]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: ACF Codifier
Plugin URI: https://github.com/devgeniem/acf-codifier
Description: A helper class to make defining ACF field groups and fields easier in the code.
Version: 1.41.2
Version: 1.41.3
Author: Miika Arponen / Geniem Oy
Author URI: https://geniem.fi
License: GPL-3.0
Expand Down
12 changes: 7 additions & 5 deletions src/Fields/MultisiteTaxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Geniem\ACF\Fields;

add_action( 'acf/init', function() {
add_action( 'acf/init', function () {
/**
* ACF MultisiteTaxonomy Relationship class
*/
Expand Down Expand Up @@ -79,7 +79,6 @@ function get_ajax_query( $options = [] ) {
]
);


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

Expand Down Expand Up @@ -201,7 +200,7 @@ protected function get_all_terms( $args ) {
] );

// parameters changed in version 4.5
if( acf_version_compare( 'wp', '<', '4.5' ) ) {
if ( acf_version_compare( 'wp', '<', '4.5' ) ) {
return get_terms( $args['taxonomy'], $args );
}

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

$nonce = wp_create_nonce( 'acf_field_' . $this->name . '_' . $field['key'] );

// vars
$div = [
'class' => 'acf-multisite-taxonomy-field',
'data-ftype' => $field['field_type'],
'data-taxonomy' => $field['taxonomy'],
'data-allow_null' => $field['allow_null'],
'data-nonce' => $nonce,
];

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

$field['multiple'] = 0;

$this->render_field_select( $field );
$this->render_field_select( $field, $nonce );

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

$field['multiple'] = 1;

$this->render_field_select( $field );
$this->render_field_select( $field, $nonce );

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

Expand Down
13 changes: 9 additions & 4 deletions src/Fields/Multitaxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,16 @@ public function render_field( $field ) {
// force value to array
$field['value'] = acf_get_array( $field['value'] );

$nonce = wp_create_nonce( 'acf_field_' . $this->name . '_' . $field['key'] );

// vars
$div = [
'class' => 'acf-multitaxonomy-field',
'data-save' => $field['save_terms'],
'data-ftype' => $field['field_type'],
'data-taxonomy' => $field['taxonomy'],
'data-allow_null' => $field['allow_null'],
'data-nonce' => $nonce,
];

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

$field['multiple'] = 0;

$this->render_field_select( $field );
$this->render_field_select( $field, $nonce );

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

$field['multiple'] = 1;

$this->render_field_select( $field );
$this->render_field_select( $field, $nonce );

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

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

/**
* Render field select
* Render field select.
*
* @param array $field The field object.
* @param string $nonce The nonce.
* @return void
*/
public function render_field_select( $field ) {
public function render_field_select( $field, $nonce ) {

// Change Field into a select
$field['type'] = 'select';
$field['ui'] = 1;
$field['ajax'] = 1;
$field['nonce'] = $nonce;
$field['choices'] = [];
$field['disabled'] = $field['disable'] ?? false;

Expand Down

0 comments on commit b5af43a

Please sign in to comment.