Last active
February 20, 2019 14:51
-
-
Save MWDelaney/ddb2b37a86949f3e68da657ab2b74ca6 to your computer and use it in GitHub Desktop.
Advanced Custom Fields drop-in functionality for Sage 9
This file contains hidden or 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
<?php | |
namespace App; | |
/** | |
* Advanced Custom Fields drop-in functionality for Sage 9 | |
* Version: 1.0 | |
* Author: Michael W. Delaney | |
*/ | |
/** | |
* 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) { | |
// Set Sage9 friendly path at /theme-directory/resources/assets/acf-json | |
$path = get_stylesheet_directory() . '/assets/acf-json'; | |
// 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'; | |
// return | |
return $paths; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment