From 7675bc275b790e4c7fa1efe6807223d53f758596 Mon Sep 17 00:00:00 2001 From: Dino Law Date: Thu, 16 Jul 2020 01:13:08 +0800 Subject: [PATCH] Fix #32: Can't use array for multisite across multiple environments --- wp-config.load.php | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/wp-config.load.php b/wp-config.load.php index b53625e..bfbea41 100644 --- a/wp-config.load.php +++ b/wp-config.load.php @@ -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)) { @@ -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; } } @@ -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; } } @@ -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);