Fix init/hooks so that we properly initialize db/plugin

- Added activation hook in main file (mailpoet.php)
- auto deactivate plugin in case of fatal errors during init
This commit is contained in:
Jonathan Labreuille
2016-01-27 12:52:40 +01:00
parent 91981cc324
commit c60425afb2
4 changed files with 39 additions and 32 deletions

View File

@ -18,22 +18,27 @@ class Initializer {
}
function init() {
$this->setupDB();
$this->setupActivator();
$this->setupRenderer();
$this->setupLocalizer();
$this->setupMenu();
$this->setupRouter();
$this->setupWidget();
$this->setupAnalytics();
$this->setupPermissions();
$this->setupChangelog();
$this->setupPublicAPI();
$this->runQueueSupervisor();
$this->setupShortcodes();
$this->setupHooks();
$this->setupPages();
$this->setupImages();
try {
$this->setupDB();
$this->setupRenderer();
$this->setupLocalizer();
$this->setupMenu();
$this->setupRouter();
$this->setupWidget();
$this->setupAnalytics();
$this->setupPermissions();
$this->setupChangelog();
$this->setupPublicAPI();
$this->runQueueSupervisor();
$this->setupShortcodes();
$this->setupHooks();
$this->setupPages();
$this->setupImages();
} catch(\Exception $e) {
// if anything goes wrong during init
// automatically deactivate the plugin
deactivate_plugins(Env::$file);
}
}
function setupDB() {
@ -81,9 +86,10 @@ class Initializer {
define('MP_NEWSLETTER_STATISTICS_TABLE', $newsletter_statistics);
}
function setupActivator() {
$activator = new Activator();
$activator->init();
function runPopulator() {
$this->init();
$populator = new Populator();
$populator->up();
}
function setupRenderer() {
@ -138,6 +144,7 @@ class Initializer {
$shortcodes = new Shortcodes();
$shortcodes->init();
}
function setupHooks() {
$hooks = new Hooks();
$hooks->init();
@ -153,7 +160,7 @@ class Initializer {
try {
$supervisor = new Supervisor();
$supervisor->checkDaemon();
} catch (\Exception $e) {
} catch(\Exception $e) {
}
}