Skip to content

Commit

Permalink
custom acf json store paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperf committed Dec 2, 2024
1 parent b753665 commit 033c034
Show file tree
Hide file tree
Showing 3 changed files with 455 additions and 2 deletions.
31 changes: 29 additions & 2 deletions site/web/app/themes/nynaeve/app/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,36 @@
/**
* Set ACF JSON Save Path Location
*
* @param string $path The default path
* @return string
*/
function my_acf_json_save_point($path) {
return get_stylesheet_directory() . '/resources/acf-json';
// Get current field group being saved
$field_group = false;
if (!empty($_POST['acf_field_group'])) {
$field_group = $_POST['acf_field_group'];
}

// Default path
$custom_path = get_stylesheet_directory() . '/resources/acf-json';

if ($field_group && isset($field_group['title'])) {
if ($field_group['title'] === 'Homepage Builder') {
$custom_path = get_stylesheet_directory() . '/resources/acf-json/homepage-builder';
} elseif ($field_group['title'] === 'Footer Options') {
$custom_path = get_stylesheet_directory() . '/resources/acf-json/footer-options';
} elseif ($field_group['title'] === 'Introduction Text') {
$custom_path = get_stylesheet_directory() . '/resources/acf-json/introduction-text';
}
}

// Create directory if it doesn't exist
if (!file_exists($custom_path)) {
wp_mkdir_p($custom_path);
}

return $custom_path;
}
add_filter('acf/settings/save_json', __NAMESPACE__ . '\\my_acf_json_save_point');
add_filter('acf/settings/save_json', __NAMESPACE__ . '\\my_acf_json_save_point');

// Homepage Builder
Loading

0 comments on commit 033c034

Please sign in to comment.