Skip to content

Instantly share code, notes, and snippets.

@MWDelaney
Last active February 20, 2019 14:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MWDelaney/ddb2b37a86949f3e68da657ab2b74ca6 to your computer and use it in GitHub Desktop.
Save MWDelaney/ddb2b37a86949f3e68da657ab2b74ca6 to your computer and use it in GitHub Desktop.
Advanced Custom Fields drop-in functionality for Sage 9
<?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