Support custom `/acf-json` locations
-
The
acfe_folder_exists($folder)
function is only used to check for the existence of theTHEME + /acf-json
folder to determine if the ACF->JSON sync is enabled. This function is a bit generic, but is only used in 2 places and both check for the same folder (./acf-json). The issue is that this path can be customized using theacf/settings/save_json
filter, and in my case I would like to save them toWP_CONTENT_DIR + /acf-json
to allow us to change themes and keep the same ACF settings.This has been added to
WP_CONTENT_DIR/mu-plugins/functions.php
:add_filter('acf/settings/save_json', function( $path ) { return WP_CONTENT_DIR . '/acf-json'; });
Instead of passing in the
$path
, using theacf_get_setting('save_json')
function to get the path will run it through the filters and then will returnis_dir()
on the correct location. Perhaps this could be a different function if you intend to check for other folders in the theme at some point./** * JSON folder Exists */ function acfe_json_folder_exists(){ $json_path = acf_get_setting('save_json'); return is_dir($json_path); }
As a side note, if you have your code somewhere I can submit a PR I would be happy to do so. Thanks!
- The topic ‘Support custom `/acf-json` locations’ is closed to new replies.