-
Notifications
You must be signed in to change notification settings - Fork 1
/
acf-5-json-storage.php
53 lines (49 loc) · 1.5 KB
/
acf-5-json-storage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* ACF 5 Pro JSON Storage
*
* @package ACF_JSON_Storage
* @author Craig Simpson <csimps@gmail.com>
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: ACF 5 Pro JSON Storage
* Plugin URI: https://github.com/craigsimps/acf-json-storage
* Description: Store ACF 5 Pro JSON outside of the default theme /acf-json/ folder.
* Version: 1.0.0
* Author: Craig Simpson
* Text Domain: acf-5-pro-json-storage
* Domain Path /languages
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* GitHub Plugin URI: craigsimps/acf-5-pro-json-storage
* GitHub Plugin URI: https://github.com/craigsimps/acf-5-pro-json-storage
*/
if ( ! defined( 'WPINC' ) ) {
die;
}
add_filter( 'acf/settings/save_json', 'ajs_acf_json_save_point' );
/**
* Change ACF JSON save point to within this plugin rather than theme.
*
* @since 1.0.0
*
* @return string Path to save ACF JSON files.
*/
function ajs_acf_json_save_point() {
return trailingslashit( plugin_dir_path( __FILE__ ) ) . 'acf-json';
}
add_filter( 'acf/settings/load_json', 'ajs_acf_json_load_point' );
/**
* Change ACF JSON load point to within this plugin rather than theme.
*
* @since 1.0.0
*
* @param array $paths Existing ACF JSON load paths.
* @return array Paths to load ACF JSON files.
*/
function ajs_acf_json_load_point( $paths ) {
unset( $paths[ 0 ] );
$paths[] = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'acf-json';
return $paths;
}