Skip to content

Instantly share code, notes, and snippets.

@phillipadsmith
Created November 19, 2012 17:39
Show Gist options
  • Save phillipadsmith/4112169 to your computer and use it in GitHub Desktop.
Save phillipadsmith/4112169 to your computer and use it in GitHub Desktop.
if ($_SERVER['REMOTE_ADDR']=='127.0.0.1') {
define('WP_ENV', 'local');
} elseif ($_SERVER['HTTP_HOST']=='develop.project.com') {
define('WP_ENV', 'develop');
} elseif ($_SERVER['HTTP_HOST']=='master.project.com') {
define('WP_ENV', 'develop');
} else {
define('WP_ENV', 'production');
}
$server = preg_replace ('/:.*/',"", $_SERVER['HTTP_HOST']);
if ( WP_ENV == 'develop' ) {
define('DB_NAME', 'project_dev');
define('DB_USER', '');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
define('WP_SITEURL', "http://$server");
define('WP_HOME', "http://$server");
define('DISALLOW_FILE_MODS',true);
} elseif ( WP_ENV == 'production' ) {
define('DB_NAME', 'project_live');
define('DB_USER', '');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
define('DISALLOW_FILE_MODS',true);
} elseif ( WP_ENV == 'local' ) {
define('WP_SITEURL', "http://$server");
define('WP_HOME', "http://$server");
define('DB_NAME', 'project_dev');
define('DB_USER', '');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
}
@afeld
Copy link

afeld commented May 13, 2013

Just used in a Wordpress+Git workshop - thanks! https://github.com/afeld/web_dev_basics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment