Skip to content

Instantly share code, notes, and snippets.

@Thomas-A-Reinert
Last active July 25, 2019 21:44
Show Gist options
  • Save Thomas-A-Reinert/29cab3e63a8e0d8add69276a8b90aafb to your computer and use it in GitHub Desktop.
Save Thomas-A-Reinert/29cab3e63a8e0d8add69276a8b90aafb to your computer and use it in GitHub Desktop.
Purpose of this Code-Snippet for WordPress 'wp-config.php' is to have a Single Configuration that does not need to be changed each Time you push a new Release to Dev / Staging / Live-Servers
<?php
if (file_exists(dirname(__FILE__) . '/wp-config-local.php')) {
// If File exists include Config for Dev-Server Environment
include(dirname(__FILE__) . '/wp-config-local.php');
} elseif (file_exists(dirname(__FILE__) . '/wp-config-staging.php')) {
// If File exists include Config for Staging-Server Environment
include(dirname(__FILE__) . '/wp-config-staging.php');
} else {
// Config for Live-Server Environment
define('DB_NAME', 'dbname');
define('DB_USER', 'dbuser');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
define('DISALLOW_FILE_EDIT', true );
define('WP_DEBUG', false);
}
// Other stuff from the usual wp-config.php like SALTS etc.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment