Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $environments = array(
- 'local-mamp' => 'localhost',
- 'local-codekit' => '5757',
- 'staging' => 'clients.monderer.com',
- 'production' => 'inno4llc.com',
- );
- // Get the hostname
- $http_host = $_SERVER['HTTP_HOST'];
- foreach($environments as $environment => $hostname) {
- if (stristr($http_host, $hostname) !== FALSE) {
- define('ENVIRONMENT', $environment);
- break;
- }
- }
- // Exit if ENVIRONMENT is undefined
- if (!defined('ENVIRONMENT')) exit('No defined database configured for this host' . $http_host);
- // Location of environment-specific configuration
- $wp_db_config = 'wp-config/wp-db-' . ENVIRONMENT . '.php';
- // Check to see if the configuration file for the environment exists
- if (file_exists(__DIR__ . '/' . $wp_db_config)) {
- require_once($wp_db_config);
- } else {
- // Exit if configuration file does not exist
- exit('No database configuration file found for this host');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement