WordPress JSON Config
The goal of this project is to abstract the wp-config.php file into a more maintainable and reproducible structure.
Usage
Require class.wp-json-config.php
in wp-config.php
like so, replacing any/all default code up to stop editing
:
define('WP_LOCAL_DEV', true);
require_once(dirname(__FILE__) . '/class.wp-json-config.php');
$config = WP_JSON_Config::getInstance()
->parseFile(dirname(__FILE__) . '/wp-config.json')
->parse({ "local": { "database": { "user": "localroot" }}})
->apply();
/* That's all, stop editing! Happy blogging. */
Notes
- Pass in the JSON you want parsed using
parse
orparseFile
as demonstrated above. - A sample JSON configuration file
wp-config.json
is included as a reference. WP_LOCAL_DEV
determines whether or not to use thelocal
orremote
JSON configuration.- Depending on
WP_LOCAL_DEV
, anylocal
/remote
settings overrideglobal
settings. - You can chain
parse
(for JSON strings/arrays) andparseFile
(for*.json
files).