Skip to content

Instantly share code, notes, and snippets.

@Thomas-A-Reinert
Last active July 25, 2019 22:18
Show Gist options
  • Save Thomas-A-Reinert/557ce500f18ae8743a8e85258391aec3 to your computer and use it in GitHub Desktop.
Save Thomas-A-Reinert/557ce500f18ae8743a8e85258391aec3 to your computer and use it in GitHub Desktop.
One WordPress wp-config.php to rule them all: Development-, Staging- and Live-Server.
<?php
/*
* One WordPress wp-config.php to rule them all: Development-, Staging- and Live-Server.
*/
// Define Environments
$environments = array(
'dev' => 'server.dev',
'staging' => 'staging.server.com',
'live' => 'www.server.com',
);
// Probe Server Name
$server_name = $_SERVER['SERVER_NAME'];
foreach($environments AS $key => $env){
if(strstr($server_name, $env)){
define('ENVIRONMENT', $key);
break;
}
}
// If no environment is set default to production
if(!defined('ENVIRONMENT')) define('ENVIRONMENT', 'live');
// Define different wp-config details depending on environment
switch(ENVIRONMENT){
case 'dev':
define('DB_NAME', 'DBNAME');
define('DB_USER', 'DBUSER');
define('DB_PASSWORD', 'PASSWORD');
define('DB_HOST', 'localhost');
define('WP_DEBUG', true);
define('WP_CACHE', false );
break;
case 'staging':
define('DB_NAME', 'DBNAME');
define('DB_USER', 'DBUSER');
define('DB_PASSWORD', 'PASSWORD');
define('DB_HOST', 'localhost');
define('WP_DEBUG', TRUE );
define( 'WP_CACHE', TRUE );
break;
case 'live':
// Whatever you want to configure that´s not already set below..
define('DB_NAME', 'DBNAME');
define('DB_USER', 'DBUSER');
define('DB_PASSWORD', 'PASSWORD');
define('DB_HOST', 'localhost');
define('WP_DEBUG', false);
define('WP_CACHE', TRUE);
define('WP_POST_REVISIONS', '10');
define('MEDIA_TRASH', true);
define('WP_MEMORY_LIMIT', '128M');
define('WP_MAX_MEMORY_LIMIT', '256M');
define('COMPRESS_CSS', true);
define('COMPRESS_SCRIPTS', true);
define('CONCATENATE_SCRIPTS', true);
define('ENFORCE_GZIP', true);
define('DISALLOW_FILE_EDIT', true);
break;
}
// Common setting for all environments after this.
$table_prefix = 'wp_';
// Language Settings
define('WPLANG', 'de_DE');
// Authentication Unique Keys and Salts.
// {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
define('AUTH_KEY', 'd@wJ;|o+0q;+;fp&+++j91~@t8N.4|rT?A|.LOB8q~G:hWx-3SX!B.N[amy^pwE5');
define('SECURE_AUTH_KEY', 'ggKPj9v{Z5Fd[L&~o|F8fUO>#HxEaOw=}FKpd-;!<z4yGNHjZ0|+OKz~KfDgwFM{');
define('LOGGED_IN_KEY', '|$B:S+:!$8=,UzEP`T?E+sH6h(f|?e[E88^2<P>Q6WyZ+4kSg>trCm-oM|KAVcdE');
define('NONCE_KEY', '89>pZ{G1Oj32MUOE[V<7z~EyP?|HO`L;dy]vK<VX+]qRadxI:4LnlL:]zsaF-1C ');
define('AUTH_SALT', 't:WsQ.R`-YcX0#Ci2p7I5>+ZZTkC6DwQa5bH-<;.&%(_.tH!+aktnYnjDe[qO`)V');
define('SECURE_AUTH_SALT', 'R2z5)gpAmZ_KL>--%~cC:US}m`]W}:ct3Rtsv-[Dj7vxk3bnKgH|rfWx6GP!oB(S');
define('LOGGED_IN_SALT', 'czRXQplk8-G1)_r}9+$sF.UU1E0A&ZFDv12+P;EMzr{bR/vg5FF>Ssvjc*of+:F#');
define('NONCE_SALT', 'uR`:MZ*rX2%RjRDCh%;)QhK-+Q_VQlN>XUh2eFZqNALJXC*fuk6IV!cIW.sO+6+L');
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) )
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment