PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.14.17
JetBackup – Backup, Restore & Migrate v3.1.14.17
3.1.23.6 3.1.23.5 3.1.23.3 3.1.22.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
123 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 (!class_exists('PDO')) {
27 throw new \Exception(
28 __('The PHP PDO extension is not installed or enabled on your server. JetBackup requires PDO to communicate with databases. Please enable the PDO extension in your PHP configuration and try again.', 'text-domain')
29 );
30 }
31
32 if (version_compare(PHP_VERSION, JetBackup::MINIMUM_PHP_VERSION, '<')) {
33 throw new \Exception(
34 sprintf(
35 __('PHP version %s or higher is required. Current version: %s', 'text-domain'),
36 JetBackup::MINIMUM_PHP_VERSION,
37 PHP_VERSION
38 )
39 );
40 }
41
42 if (version_compare(Wordpress::getVersion(), JetBackup::MINIMUM_WP_VERSION, '<')) {
43 throw new \Exception(
44 sprintf(
45 __('WordPress version %s or higher is required. Current version: %s', 'text-domain'),
46 JetBackup::MINIMUM_WP_VERSION,
47 Wordpress::getVersion()
48 )
49 );
50 }
51
52 $plugins = Wordpress::getPlugins();
53 foreach (JetBackup::PLUGIN_CONFLICTS as $plugin) {
54 if (!isset($plugins[$plugin]) || !Wordpress::isPluginActive($plugin)) continue;
55
56 throw new \Exception(
57 sprintf(
58 __('Conflicting plugin detected: %s. Using this plugin alongside JetBackup may cause unexpected behavior. Please disable it before activating JetBackup.', 'text-domain'),
59 $plugins[$plugin]['Name']
60 )
61 );
62 }
63
64 } catch (\Exception $e) {
65 wp_die(
66 sprintf(__('This plugin cannot be activated. %s', 'text-domain'), $e->getMessage()),
67 __('Plugin Activation Error', 'text-domain'),
68 ['back_link' => true]
69 );
70 }
71 }
72
73
74 public static function uninstall():void {
75 $cron = new Crontab();
76 $cron->removeCrontab();
77 }
78
79 public static function deactivate():void {
80 $cron = new Crontab();
81 $cron->removeCrontab();
82 }
83
84 public static function update($upgrader):void {
85
86 if (
87 !isset($upgrader->new_plugin_data) ||
88 !is_array($upgrader->new_plugin_data) ||
89 !isset($upgrader->new_plugin_data['Name']) ||
90 $upgrader->new_plugin_data['Name'] != JetBackup::PLUGIN_EXT_NAME
91 ) {
92 return;
93 }
94
95
96 $config = Factory::getConfig();
97
98 /*
99 // PLACEHOLDER - in case we need changes between versions, this is an example
100
101 $current_version = $config->getCurrentVersion();
102 if(!$current_version || version_compare($current_version, '3.1', '<')) {
103
104 try {
105
106
107 } catch (\Exception $e) {
108 Alert::add(
109 "JetBackup encountered an error during the update process",
110 "Error: " . $e->getMessage(),
111 Alert::LEVEL_WARNING
112 );
113 return;
114 }
115
116 }
117 */
118
119 $config->setCurrentVersion(JetBackup::VERSION);
120 $config->save();
121 }
122 }
123