diff --git a/civicrm.php b/civicrm.php index 081d36d..1e2897d 100644 --- a/civicrm.php +++ b/civicrm.php @@ -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 =