isHeartbeatEnabled()) { add_action('admin_footer', ['\JetBackup\Wordpress\UI', 'heartbeat']); add_action('wp_ajax_jetbackup_heartbeat', ['\JetBackup\Ajax\Ajax', 'heartbeat' ]); } self::_createWorkingSpace(); // Migration has to run after workspace created (new Migration())->migrate(); Destination::createDefaultDestination(); Schedule::createDefaultSchedule(); // Will create the job if not exists BackupJob::getDefaultJob(); BackupJob::getDefaultConfigJob(); // Also create default config export schedule (hidden) self::_download(); } private static function _download():void { try { $userInput = new UserInput(); $userInput->setData($_REQUEST); if($download_id = $userInput->getValidated('download_id', 0, UserInput::UINT)) { $download = new Download($download_id); if(!$download->getId()) throw new JBException('The provided download id not found'); $download->download(); } if($queue_item_id = $userInput->getValidated('queue_item_id', 0, UserInput::UINT)) { $queue_item = new QueueItem($queue_item_id); if(!$queue_item->getId()) throw new JBException('The provided queue item id not found'); $downloader = new Downloader($queue_item->getLogFile()); $downloader->download(); } } catch(JBException $e) { die('Error:' . $e->getMessage()); } } private static function _createWorkingSpace() { $folders = [ Factory::getLocations()->getDataDir(), Factory::getLocations()->getTempDir(), Factory::getLocations()->getDatabaseDir(), Factory::getLocations()->getDownloadsDir(), Factory::getLocations()->getBackupsDir(), Factory::getLocations()->getLogsDir(), ]; foreach ($folders as $folder) Util::secureFolder($folder); } public static function filterAdminBodyClass($classes) { $screen = Helper::getCurrentScreen(); if ($screen && strpos($screen, 'jetbackup') !== false) $classes .= ' jetbackup'; return $classes; } public static function actionCLI() { if (defined('WP_CLI') && WP_CLI) CLI::init(); } }