Skip to content

Commit

Permalink
Check for WP_ENV before using. Should fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
MWDelaney authored Feb 19, 2019
1 parent 4f3a39b commit eb4b4a2
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions advanced-custom-fields.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
<?php
namespace App;

/**
* Advanced Custom Fields drop-in functionality for Sage 9
* Version: 1.0
* Author: Michael W. Delaney
*/


// Hide ACF menu item in Production
if (WP_ENV == 'production') {
add_filter('acf/settings/show_admin', '__return_false');
if (defined('WP_ENV') && WP_ENV == 'production') {
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) {
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;

$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;
});


Expand All @@ -39,12 +37,11 @@
* @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) {
add_filter('acf/settings/load_json', function ($paths) {

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

// return
return $paths;

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

// return
return $paths;
});

0 comments on commit eb4b4a2

Please sign in to comment.