Skip to content

Commit

Permalink
Merge pull request #121 from totten/master-setup
Browse files Browse the repository at this point in the history
Installation - If available, use the new installer package
  • Loading branch information
totten authored Jan 19, 2018
2 parents 9063b3b + 1829630 commit 4fd42de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions civicrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,37 @@ public function add_menu_items() {
* @return void
*/
public function run_installer() {
$civicrmCore = CIVICRM_PLUGIN_DIR . 'civicrm';

$setupPaths = array(
implode(DIRECTORY_SEPARATOR, ['vendor', 'civicrm', 'civicrm-setup']),
implode(DIRECTORY_SEPARATOR, ['packages', 'civicrm-setup',]),
implode(DIRECTORY_SEPARATOR, ['setup']),
);
foreach ($setupPaths as $setupPath) {
$loader = implode(DIRECTORY_SEPARATOR, [$civicrmCore, $setupPath, 'civicrm-setup-autoload.php']);
if (file_exists($loader)) {
require_once $loader;
require_once implode(DIRECTORY_SEPARATOR, [$civicrmCore, 'CRM', 'Core', 'ClassLoader.php']);
CRM_Core_ClassLoader::singleton()->register();
\Civi\Setup::assertProtocolCompatibility(0.1);
\Civi\Setup::init([
'cms' => 'WordPress',
'srcPath' => $civicrmCore,
'setupPath' => dirname($loader),
]);
$ctrl = \Civi\Setup::instance()->createController()->getCtrl();
$ctrl->setUrls(array(
'ctrl' => admin_url() . "options-general.php?page=civicrm-install",
'res' => CIVICRM_PLUGIN_URL . 'civicrm/' . strtr($setupPath, DIRECTORY_SEPARATOR, '/') . '/res/',
'jquery.js' => CIVICRM_PLUGIN_URL . 'civicrm/bower_components/jquery/dist/jquery.min.js',
'font-awesome.css' => CIVICRM_PLUGIN_URL . 'civicrm/bower_components/font-awesome/css/font-awesome.min.css',
'finished' => admin_url('admin.php?page=CiviCRM&q=civicrm&reset=1'),
));
\Civi\Setup\BasicRunner::run($ctrl);
return;
}
}

// uses CIVICRM_PLUGIN_DIR instead of WP_PLUGIN_DIR
$installFile =
Expand Down

0 comments on commit 4fd42de

Please sign in to comment.