PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.13.4
JetBackup – Backup, Restore & Migrate v3.1.13.4
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / Wordpress / Installer.php
backup / src / JetBackup / Wordpress Last commit date
.htaccess 9 months ago Blog.php 9 months ago Helper.php 9 months ago Init.php 9 months ago Installer.php 9 months ago MySQL.php 9 months ago UI.php 9 months ago Update.php 9 months ago Wordpress.php 9 months ago index.html 9 months ago web.config 9 months ago
Installer.php
106 lines
1 <?php
2
3 namespace JetBackup\Wordpress;
4
5 use JetBackup\Alert\Alert;
6 use JetBackup\Crontab\Crontab;
7 use JetBackup\Destination\Destination;
8 use JetBackup\Exception\DBException;
9 use JetBackup\Exception\QueueException;
10 use JetBackup\Factory;
11 use JetBackup\JetBackup;
12 use Plugin_Upgrader;
13 use SleekDB\Exceptions\InvalidArgumentException;
14 use SleekDB\Exceptions\IOException;
15
16 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
17
18 class Installer {
19
20 private function __construct() {} // only static method
21
22 public static function install():void {
23
24 try {
25
26 if (version_compare(PHP_VERSION, JetBackup::MINIMUM_PHP_VERSION, '<'))
27 throw new \Exception('Error: PHP version ' . JetBackup::MINIMUM_PHP_VERSION . ' or higher is required, Current version: ' . PHP_VERSION);
28
29 if (version_compare(Wordpress::getVersion(), JetBackup::MINIMUM_WP_VERSION, '<'))
30 throw new \Exception('WordPress version ' . JetBackup::MINIMUM_WP_VERSION . ' or higher is required. Current version: ' . Wordpress::getVersion());
31
32 $plugins = Wordpress::getPlugins();
33
34 foreach (JetBackup::PLUGIN_CONFLICTS as $plugin) {
35 if(!isset($plugins[$plugin]) || !Wordpress::isPluginActive($plugin)) continue;
36 throw new \Exception('Conflicting plugin found: Using the ' . $plugins[$plugin]['Name'] . ' plugin alongside with JetBackup might interfere with our plugin functionality and is likely to cause errors, Please disable this plugin before using JetBackup.');
37 }
38
39 } catch (\Exception $e) {
40 wp_die(__('This plugin cannot be activated, Error : ' . $e->getMessage(), 'text-domain'), __('Plugin Activation Error', 'text-domain'), array(
41 'back_link' => true,
42 ));
43 }
44 }
45
46 public static function uninstall():void {
47 $cron = new Crontab();
48 $cron->removeCrontab();
49 }
50
51 public static function deactivate():void {
52 $cron = new Crontab();
53 $cron->removeCrontab();
54 }
55
56 /**
57 * @throws \JetBackup\Exception\IOException
58 */
59 public static function update($upgrader):void {
60
61 if (
62 !isset($upgrader->new_plugin_data) ||
63 !is_array($upgrader->new_plugin_data) ||
64 !isset($upgrader->new_plugin_data['Name']) ||
65 $upgrader->new_plugin_data['Name'] != JetBackup::PLUGIN_EXT_NAME
66 ) {
67 return;
68 }
69
70
71 $config = Factory::getConfig();
72 $current_version = $config->getCurrentVersion();
73
74 if(!$current_version || version_compare($current_version, '3.1', '<')) {
75
76 try {
77
78 // Add all destinations to Queue
79 $list = Destination::query()->getQuery()->fetch();
80
81 foreach ($list as $destination_details) {
82 $destination = new Destination($destination_details[JetBackup::ID_FIELD]);
83 $destination->addToQueue(false);
84 }
85 Alert::add(
86 "JetBackup has been upgraded to version " . JetBackup::VERSION,
87 "As part of the upgrade to version " . JetBackup::VERSION . ", all remote destinations have been removed. Please re-add your remote destinations to continue using them.",
88 Alert::LEVEL_WARNING
89 );
90
91 } catch (\Exception $e) {
92 Alert::add(
93 "JetBackup encountered an error during the update process",
94 "Error: " . $e->getMessage(),
95 Alert::LEVEL_WARNING
96 );
97 return;
98 }
99
100 }
101
102 $config->setCurrentVersion(JetBackup::VERSION);
103 $config->save();
104 }
105 }
106