Thanks guys, that’s an interesting idea. If I go down the route of controlling master.php myself and testing for defined constant overrides, I could potentially manage a lot of W3TC config in git, which is appealing.
Here’s an idea for how to extensibly achieve overrides in master.php:
<?php
/*
* The regular W3TC config array, but assigned to
* a variable instead of returned directly.
*/
$conf = array(...);
/*
* W3TC_CONF_OVERRIDES can be either an array
* to be merged directly, or a stringified JSON
* representation of same.
*/
if(defined('W3TC_CONF_OVERRIDES')) {
$conf_overrides = W3TC_CONF_OVERRIDES;
if(is_string($conf_overrides)) {
$conf_overrides = json_decode($conf_overrides, TRUE);
}
if(is_array($conf_overrides) && !empty($conf_overrides)) {
$conf = array_merge($conf, $conf_overrides);
}
}
return $conf;
And then in wp-config.php:
define('W3TC_CONF_OVERRIDES', json_encode(array(
'version' => 'abc123', // you probably wouldn't actually want to override this :P
'dbcache.memcached.servers' => array('local.memcache:11211')
)));
Note the JSON action, which allows defined constants to be loaded with structured data pre-PHP7.
Of course it’d be best if the plugin author adopted this as a solution, but in the meantime I’ve got something to work with!