From f5b47d0c2e97a558e044cdb1a25c14d29a5aeffc Mon Sep 17 00:00:00 2001 From: "Michael W. Delaney" Date: Tue, 4 Jun 2019 11:24:54 -0400 Subject: [PATCH] Update advanced-custom-fields.php --- advanced-custom-fields.php | 55 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/advanced-custom-fields.php b/advanced-custom-fields.php index f760520..8042556 100644 --- a/advanced-custom-fields.php +++ b/advanced-custom-fields.php @@ -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; + }); +}