Created
July 11, 2021 01:18
-
-
Save selfagency/04638581c1102757cc2c0049463b4c21 to your computer and use it in GitHub Desktop.
[dotenv wp-config.php]
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 | |
/** Enable W3 Total Cache */ | |
define('WP_CACHE', true); // Added by W3 Total Cache | |
/* Load .env */ | |
require_once 'public/vendor/autoload.php'; | |
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | |
$dotenv->load(); | |
/* Check if dev or production env */ | |
$dev = $_ENV['ENVIRONMENT'] === 'development' ? true : false; | |
/* Assign environment variables */ | |
foreach ($_ENV as $k => $v) { | |
define($k, $v); | |
} | |
/* Set custom WordPress URL */ | |
define('WP_SITEURL', 'http://' . $_ENV['HOSTNAME'] . '/cms/'); | |
define('WP_HOME', 'http://' . $_ENV['HOSTNAME']); | |
/* WordPress general settings */ | |
$table_prefix = $_ENV['DB_TABLE_PREFIX']; | |
define('WP_DEBUG', $dev); | |
define('SCRIPT_DEBUG', $dev); | |
define('WP_DEBUG_LOG', true); | |
$prodvars = array( | |
'COMPRESS_CSS', 'COMPRESS_SCRIPTS', 'ENFORCE_GZIP', | |
'WP_AUTO_UPDATE_CORE', 'DISALLOW_FILE_MODS', 'DISALLOW_FILE_EDIT' | |
); | |
foreach ($prodvars as $prodvar) { | |
define($prodvar, !$dev); | |
} | |
/* Set absolute path to WordPress and load settings */ | |
if (!defined('ABSPATH')) { | |
define('ABSPATH', dirname(__FILE__) . '/cms/'); | |
} | |
require_once ABSPATH . 'wp-settings.php'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment