-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGS-7620] define WP_HOME #115
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d3b201a
require a new application.pantheon.php file
jazzsequence 3da040a
use application.pantheon.php to define WP_HOME
jazzsequence c32ec2c
Merge branch 'default' into BUGS-7620-define-wp_home
jazzsequence bab0807
ignore internal errors in phpcs rulesets
jazzsequence 9b1b37d
linting
jazzsequence 5fafc88
ignore application.pantheon.php filename pattern
jazzsequence 465e85b
bump actions/cache to v4
jazzsequence d0edce8
patch set-output with environment var
jazzsequence 3cfe00a
add the WP_HOME and WP_SITEURL values to the environment after we def…
jazzsequence 344dea8
look for the LANDO environment variable to check for Lando
jazzsequence 8335f91
use the lando environment variable in application.php, too
jazzsequence f472387
fix spacing
jazzsequence ad16eba
ignore the putenv that we added
jazzsequence File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,42 @@ | ||
<?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'] ) && ! isset( $_ENV['LANDO'] ) ) { | ||
// 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 ); | ||
putenv( 'WP_HOME=' . $homeurl ); | ||
|
||
if ( ! env( 'WP_SITEURL' ) ) { | ||
Config::define( 'WP_SITEURL', $homeurl . '/wp' ); | ||
putenv( 'WP_SITEURL=' . $homeurl . '/wp' ); | ||
} | ||
} | ||
} |
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 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, Pantheon-managed files in a composer-managed site are brought in via a dependency, e.g. pantheon-systems/drupal-integrations for Drupal sites. For WordPress composer-managed sites, this pattern was not followed because there were not many files to manage this way. Is there any appetite to revisit this decision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ultimately, I don't know that that would leave us in a better place than adding a file for Pantheon-maintained modifications as far as merge conflicts. Currently, we're making a one-line change in a part of
application.php
that is unlikely to change much, if they've changed the file at all. If we added a dependency and moved our modifications there, we'd make changes to thecomposer.json
, which users almost certainly have made modifications to.Also, environment-specific
application.php
files is a recommended practice for Bedrock. We're going against the grain a little bit by not using the/environment/
directory, but since our changes apply to the platform and not a specific environment, this seemed to make the most sense. If people are familiar with Bedrock already, having a Pantheon-specific config file won't seem out of place.I'm not broadly opposed to the idea, but this is also code that would otherwise have already existed in
wp-config.php
(orwp-config-pantheon.php
) and I think it would be weirder to not make it part of the core project.