Skip to content

Commit 7592060

Browse files
authored
Fix MultisitePostObject AJAX query compatibility with ACF Pro 6.8.4 (#136)
1 parent 3a03259 commit 7592060

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

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.7]
10+
11+
### Fixed
12+
- Fix MultisitePostObject AJAX query compatibility with ACF Pro 6.8.4. ACF added field-type nonce validation that rejects requests where the field type doesn't match the expected type. The parent `ajax_query()` expected `'post_object'` but the field registers as `'multisite_post_object'`, causing the nonce check to fail silently.
13+
914
## [1.41.6]
1015

1116
### Added

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.6
6+
Version: 1.41.7
77
Author: Miika Arponen / Geniem Oy
88
Author URI: https://geniem.fi
99
License: GPL-3.0

src/Fields/MultisitePostObject.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,36 @@ public function input_admin_enqueue_scripts() {
5151
);
5252
}
5353

54+
/**
55+
* Override parent ajax_query to use correct field type for nonce verification.
56+
*
57+
* ACF 6.8.4 added field-type validation to AJAX nonce checks.
58+
* The parent passes 'post_object' as expected type, but this field
59+
* registers as 'multisite_post_object', causing verification to fail.
60+
*
61+
* @return void
62+
*/
63+
public function ajax_query() {
64+
$nonce = \acf_request_arg( 'nonce', '' );
65+
$key = \acf_request_arg( 'field_key', '' );
66+
$conditional_logic = (bool) \acf_request_arg( 'conditional_logic', false );
67+
68+
if ( $conditional_logic ) {
69+
if ( ! \acf_current_user_can_admin() ) {
70+
die();
71+
}
72+
73+
$nonce = '';
74+
$key = '';
75+
}
76+
77+
if ( ! \acf_verify_ajax( $nonce, $key, ! $conditional_logic, 'multisite_post_object' ) ) {
78+
die();
79+
}
80+
81+
\acf_send_ajax_results( $this->get_ajax_query( $_POST ) );
82+
}
83+
5484
/**
5585
* Switch to the selected blog when using
5686
* the parent method for fetching the AJAX response.

0 commit comments

Comments
 (0)