Skip to content

Instantly share code, notes, and snippets.

@p4ulypops
Created February 15, 2015 10:23
Show Gist options
  • Save p4ulypops/a843f3cb8a93a445b9a2 to your computer and use it in GitHub Desktop.
Save p4ulypops/a843f3cb8a93a445b9a2 to your computer and use it in GitHub Desktop.
On every WP site I do, where i'm the only developer, I add this to the config
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<?
define('WP_HOME', 'http://'.$_SERVER['SERVER_NAME']);
define('WP_SITEURL', 'http://'.$_SERVER['SERVER_NAME']);
?>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
But my Localhost/dev-enviroment I setup my own domain, such as http://website.pp (.pp = .paulypops; it's just something that doesn't exist outside of my network).
But sometimes I also do the following if I've got a few collegues
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<?
define('WP_MYENV', $_SERVER['SERVER_NAME']);
switch (WP_MYENV) {
case 'example.com': // live site
define('WP_DEUBUG', false);
define('WP_HOME', 'http://example.com');
define('WP_SITEURL', 'http://example.com');
define( 'DB_USER', 'MyUserName' );
define( 'DB_NAME', 'MyDatabaseName' );
define( 'DB_PASSWORD', 'MyPassWord' );
define( 'DB_HOST', 'MyDatabaseHost' );
break;
case 'example.pp': // My localhost dev
define('WP_DEUBUG', true);
define('WP_HOME', 'http://example.pp');
define('WP_SITEURL', 'http://example.pp');
define( 'DB_USER', 'root' );
define( 'DB_NAME', 'myDBName' );
define( 'DB_PASSWORD', '' );
define( 'DB_HOST', 'localhost' );
break;
case 'example.collegue': // a collegue's localhost
define('WP_DEUBUG', true);
define('WP_HOME', 'http://example.pp');
define('WP_SITEURL', 'http://example.pp');
define( 'DB_USER', 'root' );
define( 'DB_NAME', 'collegesDBName' );
define( 'DB_PASSWORD', '' );
define( 'DB_HOST', 'localhost' );
break;
default:
exit("Whoops, come back soon; this site needs some adjustments");
}
?>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment