Skip to content

Commit

Permalink
Fix #32: Can't use array for multisite across multiple environments
Browse files Browse the repository at this point in the history
  • Loading branch information
dino-conceptable committed Jul 15, 2020
1 parent d710e10 commit 7675bc2
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions wp-config.load.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function s24_load_environment_config() {
}
$domain = $env_vars['domain'];

$wildcard = (strpos($domain, '*') !== false) ? true : false;
$wildcard = (is_string($domain) && strpos($domain, '*') !== false) ? true : false;
if ($wildcard) {
$match = '/' . str_replace('*', '([^.]+)', preg_quote($domain, '/')) . '/';
if (preg_match($match, $hostname, $m)) {
Expand All @@ -84,10 +84,25 @@ function s24_load_environment_config() {
define('WP_ENV_DOMAIN', str_replace('*', $m[1], $domain));
if (isset($env_vars['ssl'])) {
define('WP_ENV_SSL', (bool)$env_vars['ssl']);
} else {
define('WP_ENV_SSL', false);
}
if (isset($env_vars['path'])) {
define('WP_ENV_PATH', trim($env_vars['path'], '/'));
}

/**
* Define WordPress Site URLs
*/
$protocol = (WP_ENV_SSL) ? 'https://' : 'http://';
$path = (defined('WP_ENV_PATH')) ? '/' . trim(WP_ENV_PATH, '/') : '';

if (!defined('WP_SITEURL')) {
define('WP_SITEURL', $protocol . trim(WP_ENV_DOMAIN, '/') . $path);
}
if (!defined('WP_HOME')) {
define('WP_HOME', $protocol . trim(WP_ENV_DOMAIN, '/') . $path);
}
break;
}
}
Expand All @@ -102,10 +117,25 @@ function s24_load_environment_config() {
define('WP_ENV_DOMAIN', $domain_name);
if (isset($env_vars['ssl'])) {
define('WP_ENV_SSL', (bool)$env_vars['ssl']);
} else {
define('WP_ENV_SSL', false);
}
if (isset($env_vars['path'])) {
define('WP_ENV_PATH', trim($env_vars['path'], '/'));
}

/**
* Define WordPress Site URLs
*/
$protocol = (WP_ENV_SSL) ? 'https://' : 'http://';
$path = (defined('WP_ENV_PATH')) ? '/' . trim(WP_ENV_PATH, '/') : '';

if (!defined('WP_SITEURL')) {
define('WP_SITEURL', $protocol . trim(WP_ENV_DOMAIN, '/') . $path);
}
if (!defined('WP_HOME')) {
define('WP_HOME', $protocol . trim(WP_ENV_DOMAIN, '/') . $path);
}
break;
}
}
Expand All @@ -125,19 +155,6 @@ function s24_load_environment_config() {
define('FORCE_SSL_ADMIN', true);
}

/**
* Define WordPress Site URLs
*/
$protocol = (WP_ENV_SSL) ? 'https://' : 'http://';
$path = (defined('WP_ENV_PATH')) ? '/' . trim(WP_ENV_PATH, '/') : '';

if (!defined('WP_SITEURL')) {
define('WP_SITEURL', $protocol . trim(WP_ENV_DOMAIN, '/') . $path);
}
if (!defined('WP_HOME')) {
define('WP_HOME', $protocol . trim(WP_ENV_DOMAIN, '/') . $path);
}

// Define W3 Total Cache hostname
if (defined('WP_CACHE')) {
define('COOKIE_DOMAIN', $hostname);
Expand Down

0 comments on commit 7675bc2

Please sign in to comment.