diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 382892d314b6..30bb9f98164b 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -558,23 +558,10 @@ public function cmsRootPath() { } } else { - $pathVars = explode('/', str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME'])); - - //might be windows installation. - $firstVar = array_shift($pathVars); - if ($firstVar) { - $cmsRoot = $firstVar; - } - - //start w/ csm dir search. - foreach ($pathVars as $var) { - $cmsRoot .= "/$var"; - if ($this->validInstallDir($cmsRoot)) { - //stop as we found bootstrap. - $valid = TRUE; - break; - } - } + $setting = Civi::settings()->get('wpLoadPhp'); + $path = str_replace('wp-load.php', '', $setting); + $cmsRoot = rtrim($path, '/\\'); + $valid = TRUE; } return ($valid) ? $cmsRoot : NULL;