-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CMS-802] More closely align config management to roots/bedrock (#9)
- Loading branch information
John Spellman
authored
Jul 25, 2022
1 parent
f9b1cd1
commit bc11ddb
Showing
7 changed files
with
99 additions
and
231 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DB_NAME=$_ENV['DB_NAME'] | ||
DB_USER=$_ENV['DB_USER'] | ||
DB_PASSWORD=$_ENV['DB_PASSWORD'] | ||
|
||
# Pantheon sets these values for you. If you want to shuffle them you can do so via your dashboard. | ||
AUTH_KEY=$_ENV['AUTH_KEY'] | ||
SECURE_AUTH_KEY=$_ENV['SECURE_AUTH_KEY'] | ||
LOGGED_IN_KEY=$_ENV['LOGGED_IN_KEY'] | ||
NONCE_KEY=$_ENV['NONCE_KEY'] | ||
AUTH_SALT=$_ENV['AUTH_SALT'] | ||
SECURE_AUTH_SALT=$_ENV['SECURE_AUTH_SALT'] | ||
LOGGED_IN_SALT=$_ENV['LOGGED_IN_SALT'] | ||
NONCE_SALT=$_ENV['NONCE_SALT'] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ web/.htaccess | |
.env | ||
.env.* | ||
!.env.example | ||
!.env.pantheon | ||
|
||
# Composer | ||
/vendor | ||
|
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,170 +1,70 @@ | ||
<?php | ||
/* | ||
* Don't show deprecations | ||
*/ | ||
error_reporting( E_ALL ^ E_DEPRECATED ); | ||
|
||
/** | ||
* Set root path | ||
* Pantheon platform settings. | ||
* | ||
* IMPORTANT NOTE: | ||
* Do not modify this file. This file is maintained by Pantheon. | ||
* | ||
* Site-specific modifications belong in wp-config.php, not this file. This | ||
* file may change in future releases and modifications would cause conflicts | ||
* when attempting to apply upstream updates. | ||
*/ | ||
$rootPath = realpath( __DIR__ . '/..' ); | ||
|
||
/** | ||
* Include the Composer autoload | ||
*/ | ||
require_once( $rootPath . '/vendor/autoload.php' ); | ||
|
||
/* | ||
* Fetch .env | ||
*/ | ||
if ( ! isset( $_ENV['PANTHEON_ENVIRONMENT'] ) && file_exists( $rootPath . '/.env' ) ) { | ||
$dotenv = Dotenv\Dotenv::create($rootPath); | ||
$dotenv->load(); | ||
$dotenv->required( array( | ||
'DB_NAME', | ||
'DB_USER', | ||
'DB_HOST', | ||
) )->notEmpty(); | ||
use Roots\WPConfig\Config; | ||
use function Env\env; | ||
|
||
/** A couple extra tweaks to help things run well on Pantheon. **/ | ||
if (isset($_SERVER['HTTP_HOST'])) { | ||
// HTTP is still the default scheme for now. | ||
$scheme = 'http'; | ||
// If we have detected that the end use is HTTPS, make sure we pass that | ||
// through here, so <img> tags and the like don't generate mixed-mode | ||
// content warnings. | ||
if (isset($_SERVER['HTTP_USER_AGENT_HTTPS']) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON') { | ||
$scheme = 'https'; | ||
$_SERVER['HTTPS'] = 'on'; | ||
} | ||
Config::define('WP_HOME', $scheme . '://' . $_SERVER['HTTP_HOST']); | ||
Config::define('WP_SITEURL', $scheme . '://' . $_SERVER['HTTP_HOST'] . '/wp'); | ||
} | ||
|
||
// Don't show deprecations; useful under PHP 5.5 | ||
error_reporting(E_ALL ^ E_DEPRECATED); | ||
/** Define appropriate location for default tmp directory on Pantheon */ | ||
define('WP_TEMP_DIR', sys_get_temp_dir()); | ||
|
||
/** | ||
* Disallow on server file edits | ||
* Set WP_ENVIRONMENT_TYPE according to the Pantheon Environment | ||
*/ | ||
define( 'DISALLOW_FILE_EDIT', true ); | ||
define( 'DISALLOW_FILE_MODS', true ); | ||
if (getenv('WP_ENVIRONMENT_TYPE') === false) { | ||
switch ($_ENV['PANTHEON_ENVIRONMENT']) { | ||
case 'live': | ||
putenv('WP_ENVIRONMENT_TYPE=production'); | ||
break; | ||
case 'test': | ||
putenv('WP_ENVIRONMENT_TYPE=staging'); | ||
break; | ||
default: | ||
putenv('WP_ENVIRONMENT_TYPE=development'); | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* Force SSL | ||
*/ | ||
define( 'FORCE_SSL_ADMIN', true ); | ||
if ( ! env('FORCE_SSL_ADMIN') ) { | ||
Config::define( 'FORCE_SSL_ADMIN', true ); | ||
} | ||
|
||
/** | ||
* Limit post revisions | ||
*/ | ||
define( 'WP_POST_REVISIONS', 3 ); | ||
|
||
/* | ||
* If NOT on Pantheon | ||
*/ | ||
if ( ! isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ): | ||
/** | ||
* Define site and home URLs | ||
*/ | ||
// HTTP is still the default scheme for now. | ||
$scheme = 'http'; | ||
// If we have detected that the end use is HTTPS, make sure we pass that | ||
// through here, so <img> tags and the like don't generate mixed-mode | ||
// content warnings. | ||
if ( isset( $_SERVER['HTTP_USER_AGENT_HTTPS'] ) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON' ) { | ||
$scheme = 'https'; | ||
} | ||
$site_url = getenv( 'WP_HOME' ) !== false ? getenv( 'WP_HOME' ) : $scheme . '://' . $_SERVER['HTTP_HOST'] . '/'; | ||
define( 'WP_HOME', $site_url ); | ||
define( 'WP_SITEURL', $site_url . 'wp/' ); | ||
|
||
/** | ||
* Set Database Details | ||
*/ | ||
define( 'DB_NAME', getenv( 'DB_NAME' ) ); | ||
define( 'DB_USER', getenv( 'DB_USER' ) ); | ||
define( 'DB_PASSWORD', getenv( 'DB_PASSWORD' ) !== false ? getenv( 'DB_PASSWORD' ) : '' ); | ||
define( 'DB_HOST', getenv( 'DB_HOST' ) ); | ||
|
||
/** | ||
* Set debug modes | ||
*/ | ||
define( 'WP_DEBUG', getenv( 'WP_DEBUG' ) === 'true' ? true : false ); | ||
define( 'IS_LOCAL', getenv( 'IS_LOCAL' ) !== false ? true : false ); | ||
|
||
/**#@+ | ||
* 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 | ||
*/ | ||
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' ); | ||
|
||
endif; | ||
|
||
/* | ||
* If on Pantheon | ||
* Defaults you may override | ||
* | ||
* To override, define your constant in your wp-config.php before wp-config-pantheon.php is required. | ||
*/ | ||
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ): | ||
|
||
// ** MySQL settings - included in the Pantheon Environment ** // | ||
/** The name of the database for WordPress */ | ||
define( 'DB_NAME', $_ENV['DB_NAME'] ); | ||
|
||
/** MySQL database username */ | ||
define( 'DB_USER', $_ENV['DB_USER'] ); | ||
|
||
/** MySQL database password */ | ||
define( 'DB_PASSWORD', $_ENV['DB_PASSWORD'] ); | ||
|
||
/** MySQL hostname; on Pantheon this includes a specific port number. */ | ||
define( 'DB_HOST', $_ENV['DB_HOST'] . ':' . $_ENV['DB_PORT'] ); | ||
|
||
/** 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. | ||
* | ||
* Pantheon sets these values for you also. If you want to shuffle them you | ||
* can do so via your dashboard. | ||
* | ||
* @since 2.6.0 | ||
*/ | ||
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'] ); | ||
/**#@-*/ | ||
|
||
/** A couple extra tweaks to help things run well on Pantheon. **/ | ||
if ( isset( $_SERVER['HTTP_HOST'] ) ) { | ||
// HTTP is still the default scheme for now. | ||
$scheme = 'http'; | ||
// If we have detected that the end use is HTTPS, make sure we pass that | ||
// through here, so <img> tags and the like don't generate mixed-mode | ||
// content warnings. | ||
if ( isset( $_SERVER['HTTP_USER_AGENT_HTTPS'] ) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON' ) { | ||
$scheme = 'https'; | ||
} | ||
define( 'WP_HOME', $scheme . '://' . $_SERVER['HTTP_HOST'] ); | ||
define( 'WP_SITEURL', $scheme . '://' . $_SERVER['HTTP_HOST'] . '/wp' ); | ||
|
||
} | ||
|
||
// 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 ) ); | ||
endif; | ||
|
||
// FS writes aren't permitted in test or live, so we should let WordPress know to disable relevant UI | ||
if ( in_array( $_ENV['PANTHEON_ENVIRONMENT'], array( 'test', 'live' ) ) && ! defined( 'DISALLOW_FILE_MODS' ) ) : | ||
define( 'DISALLOW_FILE_MODS', true ); | ||
endif; | ||
|
||
endif; | ||
/** Disable wp-cron.php from running on every page load and rely on Pantheon to run cron via wp-cli */ | ||
$network = isset($_ENV["FRAMEWORK"]) && $_ENV["FRAMEWORK"] === "wordpress_network"; | ||
if ( ! env( 'DISABLE_WP_CRON' ) && $network === false ) { | ||
Config::define('DISABLE_WP_CRON', true); | ||
} |
Oops, something went wrong.