Last active
March 26, 2021 05:34
-
-
Save wpscholar/f01c842c9417601ce277086ddefa6963 to your computer and use it in GitHub Desktop.
My Pantheon wp-config.php template.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define( 'SITE_LIVE_DOMAIN', SITE_LIVE_DOMAIN ); | |
define( 'WP_ENV', isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ? $_ENV['PANTHEON_ENVIRONMENT'] : 'local' ); | |
define( 'SCHEME', isset( $_SERVER['HTTP_USER_AGENT_HTTPS'] ) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON' ? 'https' : 'http' ); | |
// Redirect all traffic on live site to the correct domain | |
if ( 'live' === WP_ENV && php_sapi_name() !== 'cli' ) { | |
if ( $_SERVER['HTTP_HOST'] !== SITE_LIVE_DOMAIN ) { | |
header( 'HTTP/1.0 301 Moved Permanently' ); | |
header( 'Location: https://' . SITE_LIVE_DOMAIN . $_SERVER['REQUEST_URI'] ); | |
exit(); | |
} | |
} | |
// Set home and site url | |
if ( isset( $_SERVER['HTTP_HOST'] ) ) { | |
define( 'WP_HOME', SCHEME . '://' . $_SERVER['HTTP_HOST'] ); | |
define( 'WP_SITEURL', SCHEME . '://' . $_SERVER['HTTP_HOST'] ); | |
} | |
// Pantheon Environment | |
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) { | |
define( 'DB_NAME', $_ENV['DB_NAME'] ); | |
define( 'DB_USER', $_ENV['DB_USER'] ); | |
define( 'DB_PASSWORD', $_ENV['DB_PASSWORD'] ); | |
define( 'DB_HOST', $_ENV['DB_HOST'] . ':' . $_ENV['DB_PORT'] ); | |
/**#@+ | |
* @link https://api.wordpress.org/secret-key/1.1/salt/ | |
*/ | |
define( 'AUTH_KEY', $_ENV['AUTH_KEY'] ); | |
define( 'SECURE_AUTH_KEY', $_ENV['SECURE_AUTH_KEY'] ); | |
define( 'LOGGED_IN_KEY', $_ENV['LOGGED_IN_KEY'] ); | |
define( 'NONCE_KEY', $_ENV['NONCE_KEY'] ); | |
define( 'AUTH_SALT', $_ENV['AUTH_SALT'] ); | |
define( 'SECURE_AUTH_SALT', $_ENV['SECURE_AUTH_SALT'] ); | |
define( 'LOGGED_IN_SALT', $_ENV['LOGGED_IN_SALT'] ); | |
define( 'NONCE_SALT', $_ENV['NONCE_SALT'] ); | |
/**#@-*/ | |
// Don't show deprecations; useful under PHP 5.5 | |
error_reporting( E_ALL ^ E_DEPRECATED ); | |
// Force the use of a safe temp directory when in a container | |
if ( defined( 'PANTHEON_BINDING' ) ) { | |
define( 'WP_TEMP_DIR', sprintf( '/srv/bindings/%s/tmp', PANTHEON_BINDING ) ); | |
} | |
// FS writes aren't permitted in test or live, so we should let WordPress know to disable relevant UI | |
if ( in_array( WP_ENV, array( 'test', 'live' ) ) && ! defined( 'DISALLOW_FILE_MODS' ) ) { | |
define( 'DISALLOW_FILE_MODS', true ); | |
} | |
} | |
// Local Environment | |
if ( 'local' === WP_ENV ) { | |
// Check for local config file | |
if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) { | |
require_once( dirname( __FILE__ ) . '/wp-config-local.php' ); | |
} else { | |
define( 'DB_NAME', DB_NAME ); | |
define( 'DB_USER', 'root' ); | |
define( 'DB_PASSWORD', 'root' ); | |
define( 'DB_HOST', 'localhost' ); | |
define( 'SCRIPT_DEBUG', true ); | |
/**#@+ | |
* @link https://api.wordpress.org/secret-key/1.1/salt/ | |
*/ | |
define( 'AUTH_KEY', 'put your unique phrase here' ); | |
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' ); | |
define( 'LOGGED_IN_KEY', 'put your unique phrase here' ); | |
define( 'NONCE_KEY', 'put your unique phrase here' ); | |
define( 'AUTH_SALT', 'put your unique phrase here' ); | |
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); | |
define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); | |
define( 'NONCE_SALT', 'put your unique phrase here' ); | |
/**#@-*/ | |
} | |
} | |
if ( ! defined( 'DB_CHARSET' ) ) { | |
define( 'DB_CHARSET', 'utf8' ); | |
} | |
if ( ! defined( 'DB_COLLATE' ) ) { | |
define( 'DB_COLLATE', '' ); | |
} | |
if ( ! defined( 'WPLANG' ) ) { | |
define( 'WPLANG', '' ); | |
} | |
if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) ) { | |
define( 'IMAGE_EDIT_OVERWRITE', true ); | |
} | |
if ( ! defined( 'WP_DEBUG' ) ) { | |
define( 'WP_DEBUG', 'live' !== WP_ENV ); | |
} | |
if ( ! defined( 'WP_POST_REVISIONS' ) ) { | |
define( 'WP_POST_REVISIONS', 10 ); | |
} | |
if ( ! defined( 'DISALLOW_FILE_EDIT' ) ) { | |
define( 'DISALLOW_FILE_EDIT', true ); | |
} | |
if ( ! defined( 'ABSPATH' ) ) { | |
define( 'ABSPATH', dirname( __FILE__ ) . '/' ); | |
} | |
if ( ! isset( $table_prefix ) ) { | |
$table_prefix = 'wp_'; | |
} | |
require_once( ABSPATH . 'wp-settings.php' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment