Created
November 8, 2023 23:27
-
-
Save nathan-roberts/ad9f984bf421edb3657ff7cc171f3f2c to your computer and use it in GitHub Desktop.
ACF JSON - Save Specific Groups within Plugin
This file contains 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
// Save ACF JSON for specific field groups only | |
add_filter('acf/update_field_group', 'hof_acf_json_save_for_specific_groups', 10, 1); | |
function hof_acf_json_save_for_specific_groups($field_group) | |
{ | |
// Define your allowed field groups | |
$allowed_field_groups = array('group_650da9580c565'); // Replace with your actual field group keys | |
// Check if the current field group is allowed | |
if (in_array($field_group['key'], $allowed_field_groups)) { | |
// Set the save path only for allowed field groups | |
add_filter('acf/settings/save_json', 'hof_acf_json_save_point'); | |
} | |
return $field_group; | |
} | |
// Custom save point for ACF JSON | |
function hof_acf_json_save_point($path) | |
{ | |
// update path | |
$path = plugin_dir_path(__FILE__) . 'acf-json'; | |
// return | |
return $path; | |
} | |
// Load ACF JSON for specific field groups only | |
add_filter('acf/settings/load_json', 'hof_acf_json_load_point'); | |
function hof_acf_json_load_point($paths) | |
{ | |
// Your custom load logic here if needed | |
$paths[] = plugin_dir_path(__FILE__) . 'acf-json'; | |
return $paths; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment