Skip to content

Commit

Permalink
Update advanced-custom-fields.php
Browse files Browse the repository at this point in the history
  • Loading branch information
MWDelaney authored Jun 4, 2019
1 parent be772a4 commit f5b47d0
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions advanced-custom-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,39 @@
add_filter('acf/settings/show_admin', '__return_false');
}

/**
* Set local json save path
* @param string $path unmodified local path for acf-json
* @return string our modified local path for acf-json
*/
add_filter('acf/settings/save_json', function ($path) {
if (function_exists('add_filter')) {

// Set Sage9 friendly path at /theme-directory/resources/assets/acf-json
$path = get_stylesheet_directory() . '/assets/acf-json';
/**
* Set local json save path
* @param string $path unmodified local path for acf-json
* @return string our modified local path for acf-json
*/
add_filter('acf/settings/save_json', function ($path) {

// If the directory doesn't exist, create it.
if (!is_dir($path)) {
mkdir($path);
}
// Set Sage9 friendly path at /theme-directory/resources/assets/acf-json
$path = get_stylesheet_directory() . '/assets/acf-json';

// Always return
return $path;
});
// If the directory doesn't exist, create it.
if (!is_dir($path)) {
mkdir($path);
}

// Always return
return $path;
});

/**
* Set local json load path
* @param string $path unmodified local path for acf-json
* @return string our modified local path for acf-json
*/
add_filter('acf/settings/load_json', function ($paths) {

// append path
$paths[] = get_stylesheet_directory() . '/assets/acf-json';
/**
* Set local json load path
* @param string $path unmodified local path for acf-json
* @return string our modified local path for acf-json
*/
add_filter('acf/settings/load_json', function ($paths) {

// append path
$paths[] = get_stylesheet_directory() . '/assets/acf-json';

// return
return $paths;
});
// return
return $paths;
});
}

0 comments on commit f5b47d0

Please sign in to comment.