Skip to content
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

Simplify the wp-config #16

Open
Tracked by #8417
carl-alberto opened this issue May 8, 2023 · 0 comments · May be fixed by #17
Open
Tracked by #8417

Simplify the wp-config #16

carl-alberto opened this issue May 8, 2023 · 0 comments · May be fixed by #17
Labels
enhancement New feature or request good first issue Good for newcomers needs testing Solution looks good but needs testing before merging

Comments

@carl-alberto
Copy link
Contributor

carl-alberto commented May 8, 2023

Instead of having complicated wp-config which forces a specific subdomain on non live env which complicates the initial config specially if a user will be using custom domains on other envs

if ( !empty( $_ENV['PANTHEON_ENVIRONMENT'] )) {
$site_name = $_ENV['PANTHEON_SITE_NAME'];
// Override $hostname value as needed.
switch ( $_ENV['PANTHEON_ENVIRONMENT'] ) {
case 'live':
$hostname = $_SERVER['HTTP_HOST'];
break;
case 'test':
$hostname = 'test-' . $site_name . '.pantheonsite.io';
break;
case 'dev':
$hostname = 'dev-' . $site_name . '.pantheonsite.io';
break;
case 'lando':
$hostname = $site_name . '.lndo.site';
break;
default:
$hostname = $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $site_name . '.pantheonsite.io';
break;
}
} else {
// Override with a default hostname.
$hostname = '<?php echo $hostname ?>';
}
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> );
define( 'DOMAIN_CURRENT_SITE', $hostname );
define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

if ( !empty( $_ENV['PANTHEON_ENVIRONMENT'] )) {
    $site_name = $_ENV['PANTHEON_SITE_NAME'];
    // Override $hostname value as needed.
    switch ( $_ENV['PANTHEON_ENVIRONMENT'] ) {
        case 'live':
            $hostname = $_SERVER['HTTP_HOST'];
            break;
        case 'test':
            $hostname = 'test-' . $site_name . '.pantheonsite.io';
            break;
        case 'dev':
            $hostname = 'dev-' . $site_name . '.pantheonsite.io';
            break;
        case 'lando':
            $hostname = $site_name . '.lndo.site';
            break;
        default:
            $hostname = $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $site_name . '.pantheonsite.io';
            break;
    }
} else {
    // Override with a default hostname.
    $hostname = 'dev-example.pantheonsite.io';
}
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', $hostname );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Replace it with a simpler one that is proven that works on subfolder & subdomain setup that dynamically works on any subdomain

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
@jazzsequence jazzsequence added enhancement New feature or request good first issue Good for newcomers needs testing Solution looks good but needs testing before merging labels Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers needs testing Solution looks good but needs testing before merging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants