Skip to content
Snippets Groups Projects
Commit 461096bb authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #433 from dlobo/CRM-12356

Give WP more flexibility in layout of WP code vs CiviCRM location
parents cf31b053 dfbcf0b7
No related branches found
No related tags found
No related merge requests found
...@@ -433,26 +433,42 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { ...@@ -433,26 +433,42 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
return true; return true;
} }
function validInstallDir($dir) {
$includePath = "$dir/wp-includes";
if (
@opendir($includePath) &&
file_exists("$includePath/version.php")
) {
return TRUE;
}
return FALSE;
}
function cmsRootPath() { function cmsRootPath() {
$cmsRoot = $valid = NULL; $cmsRoot = $valid = NULL;
$pathVars = explode('/', str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME'])); if (defined('CIVICRM_CMSDIR')) {
if ($this->validInstallDir(CIVICRM_CMSDIR)) {
//might be windows installation. $cmsRoot = CIVICRM_CMSDIR;
$firstVar = array_shift($pathVars); $valid = TRUE;
if ($firstVar) { }
$cmsRoot = $firstVar;
} }
else {
$pathVars = explode('/', str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']));
//start w/ csm dir search. //might be windows installation.
foreach ($pathVars as $var) { $firstVar = array_shift($pathVars);
$cmsRoot .= "/$var"; if ($firstVar) {
$cmsIncludePath = "$cmsRoot/wp-includes"; $cmsRoot = $firstVar;
//stop as we found bootstrap. }
if (@opendir($cmsIncludePath) &&
file_exists("$cmsIncludePath/version.php") //start w/ csm dir search.
) { foreach ($pathVars as $var) {
$valid = TRUE; $cmsRoot .= "/$var";
break; if ($this->validInstallDir($cmsRoot)) {
//stop as we found bootstrap.
$valid = TRUE;
break;
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment