Skip to content

Commit

Permalink
use application.pantheon.php to define WP_HOME
Browse files Browse the repository at this point in the history
and make it available for future application.php modifications
  • Loading branch information
jazzsequence committed Apr 8, 2024
1 parent d3b201a commit 3da040a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions config/application.pantheon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Pantheon platform application settings.
*
* IMPORTANT NOTE:
* Do not modify this file. This file is maintained by Pantheon.
*
* Site-specific modifications belong in config/application.php, not this file.
* This file may change in future releases and modifications would cause
* conflicts when attempting to apply upstream updates.
*/

use Roots\WPConfig\Config;
use function Env\env;

if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) && 'lando' !== $_ENV['PANTHEON_ENVIRONMENT'] ) {
// We can use PANTHEON_SITE_NAME here because it's safe to assume we're on a Pantheon environment if PANTHEON_ENVIRONMENT is set.
$sitename = $_ENV['PANTHEON_SITE_NAME'];
$baseurl = $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $sitename . '.pantheonsite.io';

$scheme = 'http';
if ( isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ) {
$scheme = 'https';
}

// Define the WP_HOME and WP_SITEURL constants if they aren't already defined.
if ( ! env( 'WP_HOME' ) ) {
// If HTTP_HOST is set, use that as the base URL. It's probably more accurate.
if ( isset( $_SERVER['HTTP_HOST'] ) ) {
$baseurl = $_SERVER['HTTP_HOST'];
}

$homeurl = $scheme . '://' . $baseurl;
Config::define( 'WP_HOME', $homeurl );

if ( ! env( 'WP_SITEURL' ) ) {
Config::define( 'WP_SITEURL', $homeurl . '/wp' );
}
}
}

0 comments on commit 3da040a

Please sign in to comment.