Use with W3 Total Cache
silverl opened this issue · comments
Just found your multi-environment config and am checking it out.
I use the W3 Total Cache plugin, and it modifies wp-config.php.
In my wp-config.php, I have the following at the very top:
define('COOKIE_DOMAIN', 'my.domain.com'); // Added by W3 Total Cache
/** Enable W3 Total Cache */
define('WP_CACHE', true); // Added by W3 Total Cache
/** Enable W3 Total Cache Edge Mode */
define('W3TC_EDGE_MODE', true); // Added by W3 Total Cache
I think that setting of COOKIE_DOMAIN by W3 is going to cause problems. Have you encountered this in your practice?
I'm thinking the "fix" will be to just override the defined value for COOKIE_DOMAIN in my own environment-specific configs.
It would be possible to add these configuration values to line 57/58 of wp-config.php after the hostname gets defined. This will ensure that the current COOKIE_DOMAIN is based on the current hostname, so no need to use a seperate one for each environment.
// Define site host
if (isset($_SERVER['X_FORWARDED_HOST']) && !empty($_SERVER['X_FORWARDED_HOST'])) {
$hostname = $_SERVER['X_FORWARDED_HOST'];
} else {
$hostname = $_SERVER['HTTP_HOST'];
}
define('COOKIE_DOMAIN', $hostname); // Added by W3 Total Cache
/** Enable W3 Total Cache */
define('WP_CACHE', true); // Added by W3 Total Cache
/** Enable W3 Total Cache Edge Mode */
define('W3TC_EDGE_MODE', true); // Added by W3 Total Cache
Great, thanks.
The only config that needs to get overridden is COOKIE_DOMAIN. W3 will continue to inject all three settings in the top of wp-config.php.
hi - sorry I haven't replied to this for a while.
I added support for WP Total Cache as per the suggestion in the test branch at https://github.com/studio24/wordpress-multi-env-config/blob/feature/wp-total-cache/wp-config.php
When I get back to the office I'll test this and if it's OK with merge into the master branch
Fixed in the latest release v1.0.2 - https://github.com/studio24/wordpress-multi-env-config/releases/tag/v1.0.2