Skip to content

Instantly share code, notes, and snippets.

@calvez
Last active April 12, 2018 20:07
Show Gist options
  • Save calvez/2d68388d6a36b7f837b3834f8483f2bf to your computer and use it in GitHub Desktop.
Save calvez/2d68388d6a36b7f837b3834f8483f2bf to your computer and use it in GitHub Desktop.
// Found at:
// https://github.com/wp-cli/wp-cli/issues/1734#issuecomment-87897943
//
// Note that $_SERVER['DOCUMENT_ROOT'] will return a string with a trailing slash on
// some systems and not others, so we'll make sure it's gone in all cases where there
// is ambiguity by using rtrim.
// Also note that this is above the loading of the wp-config-*.php files so that these can
// be over-ridden as required.
<?php /* php tag is just for gist highlight*/
$md_http = ($_SERVER['HTTPS']) ? 'https://': 'http://';
$md_server_name = rtrim($_SERVER['SERVER_NAME'],"/");
$md_document_root = rtrim($_SERVER['DOCUMENT_ROOT'],"/");
// The wordpress install is in its own folder, so we force that setting here
define('WP_SITEURL', $md_http . $md_server_name . '/wordpress');
define('WP_HOME', $md_http . $md_server_name);
// The wordpress wp-content folder is outside of the git WordPress submodule so
// tell WP where it is. These may have to be set manually in some cases
define('WP_CONTENT_URL', $md_http . $md_server_name . '/wp-content');
define('WP_CONTENT_DIR', $md_document_root . '/wp-content');
// Four stages
// local = local development on my workstation
// staging = site is on my staging server
// live = site is live and under my ongoing maintenance
// released = site is live and I play no role in maintenance. In this case, the logic
// block below is removed and everything reverts back to a single file, and all traces
// of git are purged leaving a normal site. This is all done manually btw.
if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) {
define( 'MD_LOCAL_DEV', true );
include( dirname( __FILE__ ) . '/wp-config-local.php' );
// I don't need cron running, so turn it off
define( 'DISABLE_WP_CRON', true );
} else if ( file_exists( dirname( __FILE__ ) . '/wp-config-staging.php' ) ) {
define( 'MD_STAGING_DEV', true );
include( dirname( __FILE__ ) . '/wp-config-staging.php' );
// Disable all core updates, as they are handled on local machine and done via git
define( 'WP_AUTO_UPDATE_CORE', false );
define( 'DISALLOW_FILE_MODS', true );
define( 'AUTOMATIC_UPDATER_DISABLED', true );
// I Handle cron via system cron, so disable wp_cron
define( 'DISABLE_WP_CRON', true );
} else if ( file_exists( dirname( __FILE__ ) . '/wp-config-live.php' ) ) {
define( 'MD_LIVE', true );
include( dirname( __FILE__ ) . '/wp-config-live.php' );
//Disable all core updates, as they are handled on local machine and done via git
define( 'WP_AUTO_UPDATE_CORE', false );
define( 'DISALLOW_FILE_MODS', true );
define( 'AUTOMATIC_UPDATER_DISABLED', true );
// Disable all debugging
define('WP_DEBUG', false);
}
// NOTE: If upgrading from an old installation and DB_CHARSET and DB_COLLATE do not exist
// in the wp-config.php file, DO NOT ADD THEM. Read more here
// https://codex.wordpress.org/Editing_wp-config.php#Database_character_set
// Database Charset to use in creating database tables.
define('DB_CHARSET', 'utf8');
// The Database Collate type. Don't change this if in doubt.
define('DB_COLLATE', '');
/**
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
// NOTE: This is a placeholder replaced with new salts via the site creation script
// It will throw an error if not done correctly. This is by design.
define('AUTH_KEY', '+/l:+c+^-RimCPsX7D]|[ G7>Yq2+lP T2[7/If2p-.${)((v-c<ubi*<8QOF.Q_');
define('SECURE_AUTH_KEY', 'FKgfL}M)DW6I5iQ-8pqF-op{6{o&d4KNHWxA|~jdR&kXO<(%AD`*i|RCp>S1>XDq');
define('LOGGED_IN_KEY', ')|adOIXS>U(x 0UOV^.LhebLn_GUk,^x.I-0~R6<ig;q|e2X%ri`mG4S%cO2NYE|');
define('NONCE_KEY', 'G;tydGEsOy1`Wg9d%x{_+j~Z7@DI}^)fq$fNTu!82oVU!5S|y+lS[s~()&0fz&]-');
define('AUTH_SALT', 'Z1TvD2qp|ZJF.:uS3#P]%U/J&|ktGQe}HA@NQVXBFW?GM{?n.!h:aK!o-]hpU 5G');
define('SECURE_AUTH_SALT', ' 3NK2z#TK,X1FIv6#4C0iEQl$}ebQ{|-IHEm.wo;6/Fsp;8$xmb:]K?m,>6-`z.-');
define('LOGGED_IN_SALT', 'o+oy|<p/*m+>w}?n8!V^ybzDq*q-NiJ5NuQ0%FF/-I3w?zspN T!3C&b`_!YIADI');
define('NONCE_SALT', '6lhg~>o:FBfm|j H<Nb++tqg$zyjp--?VWs$XAOa+T3{aN}dZq)4FBzo^54n)xz*');
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
define('WPLANG', '');
/* 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