Last active
November 7, 2024 15:22
-
-
Save christianwach/608bf11926575e824012f1ea18a38e72 to your computer and use it in GitHub Desktop.
Temporary fix for AJAX selectors in ACF 6.3.10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ACFE Fix AJAX selectors | |
* | |
* Plugin Name: ACFE Fix AJAX selectors | |
* Description: Fixes AJAX selectors with ACF 6.3.10. Do not deacticate or delete. | |
* Plugin URI: https://haystack.co.uk | |
* Version: 1.0.0 | |
* Author: Christian Wach | |
* Author URI: https://haystack.co.uk | |
*/ | |
// Exit if accessed directly. | |
defined( 'ABSPATH' ) || exit; | |
/** | |
* Fixes "Field Groups" selector with ACF 6.3.10. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $field The ACF Field. | |
* @return array $field The modified ACF Field. | |
*/ | |
function acfe_fix_acf_6_3_10_form_field_groups( $field ){ | |
if ( acf_maybe_get( $field, 'ajax_action' ) === 'acfe/form/map_field_groups_ajax' ) { | |
$field['nonce'] = wp_create_nonce( $field['key'] ); // Add classic nonce. | |
} | |
return $field; | |
} | |
add_filter( 'acf/prepare_field/key=field_field_groups', 'acfe_fix_acf_6_3_10_form_field_groups' ); | |
/** | |
* Fixes Post/User/Term Actions selector with ACF 6.3.10. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $field The ACF Field. | |
* @return array $field The modified ACF Field. | |
*/ | |
function acfe_fix_acf_6_3_10_form_fields( $field ) { | |
if ( acf_maybe_get( $field, 'ajax_action' ) === 'acfe/form/map_field_ajax' ) { | |
$field['nonce'] = wp_create_nonce( $field['key'] );// Add classic nonce. | |
} | |
return $field; | |
} | |
add_filter( 'acf/prepare_field/type=select', 'acfe_fix_acf_6_3_10_form_fields' ); | |
add_filter( 'acf/prepare_field/type=acfe_post_types', 'acfe_fix_acf_6_3_10_form_fields' ); | |
add_filter( 'acf/prepare_field/type=acfe_post_statuses', 'acfe_fix_acf_6_3_10_form_fields' ); | |
add_filter( 'acf/prepare_field/type=acfe_taxonomy_terms', 'acfe_fix_acf_6_3_10_form_fields' ); | |
add_filter( 'acf/prepare_field/type=acfe_taxonomies', 'acfe_fix_acf_6_3_10_form_fields' ); | |
add_filter( 'acf/prepare_field/type=acfe_user_roles', 'acfe_fix_acf_6_3_10_form_fields' ); | |
/** | |
* Fixes Profile Sync Actions selector with ACF 6.3.10. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $field The ACF Field. | |
* @return array $field The modified ACF Field. | |
*/ | |
function acfe_fix_acf_6_3_10_select_form_fields( $field ) { | |
$action = acf_maybe_get( $field, 'ajax_action' ); | |
if ( $action === 'cwps_get_country_field' || $action === 'cwps_get_state_field' ) { | |
$field['nonce'] = wp_create_nonce( $field['key'] );// Add classic nonce. | |
} | |
return $field; | |
} | |
add_filter( 'acf/prepare_field/type=select', 'acfe_fix_acf_6_3_10_select_form_fields' ); | |
/** | |
* Fixes Profile Sync Actions selector with ACF 6.3.10. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $field The ACF Field. | |
* @return array $field The modified ACF Field. | |
*/ | |
function acfe_fix_acf_6_3_10_profile_sync_form_fields( $field ) { | |
$field['nonce'] = wp_create_nonce( $field['key'] );// Add classic nonce. | |
return $field; | |
} | |
add_filter( 'acf/prepare_field/type=civicrm_activity_assignee', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); | |
add_filter( 'acf/prepare_field/type=civicrm_activity_creator', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); | |
add_filter( 'acf/prepare_field/type=civicrm_activity_target', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); | |
add_filter( 'acf/prepare_field/type=civicrm_contact', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); | |
add_filter( 'acf/prepare_field/type=civicrm_contact_ref', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); | |
add_filter( 'acf/prepare_field/type=civicrm_event', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); | |
add_filter( 'acf/prepare_field/type=civicrm_relationship', 'acfe_fix_acf_6_3_10_profile_sync_form_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment