$tempURL = str_replace("/administrator/", "/", $baseURL);
$filesURL = $tempURL . "media/civicrm/";
}
- elseif ($config->userFramework == 'WordPress') {
- //for standalone no need of sites/defaults directory
- $filesURL = $baseURL . "wp-content/plugins/files/civicrm/";
- }
elseif ($this->is_drupal) {
$siteName = $config->userSystem->parseDrupalSiteName($civicrm_root);
if ($siteName) {
}
}
+ /**
+ * Moved from CRM_Utils_System_Base
+ */
+ public function getDefaultFileStorage() {
+ global $civicrm_root;
+ $config = CRM_Core_Config::singleton();
+ $baseURL = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
+
+ $filesURL = NULL;
+ $filesPath = NULL;
+ $upload_dir = wp_upload_dir();
+ $settingsDir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR;
+ $settingsURL = $upload_dir['baseurl'] . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR;
+ if (is_dir(ABSPATH . 'wp-content/plugins/files/civicrm/')) {
+ //for legacy path
+ $filesURL = $baseURL . "wp-content/plugins/files/civicrm/";
+ }
+ elseif (is_dir($settingsDir)) {
+ $filesURL = $settingsURL;
+ }
+ else {
+ throw new CRM_Core_Exception("Failed to locate default file storage ($config->userFramework)");
+ }
+
+ return array(
+ 'url' => $filesURL,
+ 'path' => CRM_Utils_File::baseFilePath(),
+ );
+ }
+
/**
* @inheritDoc
*/
);
}
elseif ($installType == 'wordpress') {
- civicrm_setup(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'files');
+ $upload_dir = wp_upload_dir();
+ $files_dirname = $upload_dir['basedir'];
+ civicrm_setup($files_dirname);
}
$dsn = "mysql://{$config['mysql']['username']}:{$config['mysql']['password']}@{$config['mysql']['server']}/{$config['mysql']['database']}?new_link=true";
$configFile = $cmsPath . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . $siteDir . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
}
elseif ($installType == 'wordpress') {
- $configFile = $cmsPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
+ $configFile = $files_dirname . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
}
$string = civicrm_config($config);
$databaseConfig = $_REQUEST['mysql'];
}
else {
- $databaseConfig = array(
- "server" => "localhost",
- "username" => "civicrm",
- "password" => "",
- "database" => "civicrm",
- );
+ if ($installType == 'wordpress') {
+ //WP Database Data
+ $databaseConfig = array(
+ "server" => DB_HOST,
+ "username" => DB_USER,
+ "password" => DB_PASSWORD,
+ "database" => DB_NAME,
+ );
+ }
}
if ($installType == 'drupal') {
}
elseif ($installType == 'wordpress') {
$cmsPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm';
+ $upload_dir = wp_upload_dir();
+ $files_dirname = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm';
$alreadyInstalled = file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR .
'civicrm.settings.php'
);
);
}
elseif ($installType == 'wordpress') {
- // make sure that we can write to plugins/civicrm and plugins/files/
- $writableDirectories = array(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'files', $cmsPath);
+ // make sure that we can write to uploads/civicrm/
+ $upload_dir = wp_upload_dir();
+ $files_dirname = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm';
+ if (!file_exists($files_dirname)) {
+ wp_mkdir_p($files_dirname);
+ }
+ $writableDirectories = array($files_dirname);
}
foreach ($writableDirectories as $dir) {
$c = CRM_Core_Config::singleton(FALSE);
$c->free();
+ $wpInstallRedirect = admin_url("?page=CiviCRM&q=civicrm&reset=1");
+ echo "<script>
+ window.location = '$wpInstallRedirect';
+ </script>";
}
}