boot(); } return self::$instance; } public function boot() { $this->init_hooks(); $this->ajax = new AdminAjax(); } public function init_hooks() { add_action('init', [$this, 'init_core_classes'], 0); register_activation_hook(ALERTWISE_FILE, ['\Alertwise\Installer', 'plugin_install']); register_uninstall_hook(ALERTWISE_FILE, ['\Alertwise\Uninstaller', 'plugin_uninstall']); add_action('admin_init', ['\Alertwise\Upgrade', 'plugin_upgrade']); set_error_handler([$this, 'alertwise_error_handler']); set_exception_handler([$this, 'alertwise_exception_handler']); } public function alertwise_error_handler($errNo, $errStr, $errFile, $errLine) { if (strpos($errFile, 'alertwise') === false) return; AlertwiseAPI::instance()->post_log_info('ERROR', $errStr, "File => $errFile | Line => $errLine", 'ERROR'); } public function alertwise_exception_handler($exception) { AlertwiseAPI::instance()->post_log_info( 'EXCEPTION', $exception->getMessage(), "File => $exception->getFile() | Line => $exception->getLine()", 'EXCEPTION' ); } public function init_core_classes() { $this->admin = new Admin(); $this->enqueue_assets = new EnqueueAssets(); $this->nav_menu = new NavMenu(); $this->service_worker = new ServiceWorker(); $this->sendingManager = new SendManager(); $this->dashboard_widget = new DashboardWidget(); $this->dashboard_notice = new DashboardNotices(); $this->dashboard_overview_widget = new DashboardOverviewWidget(); } public static function output_view($filename, $data = []) { $view_file = ALERTWISE_VIEWS_PATH . DIRECTORY_SEPARATOR . basename($filename); if (!file_exists($view_file)) { return; } if (is_array($data)) { extract($data); } require $view_file; } }