PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / trunk
JetBackup – Backup, Restore & Migrate vtrunk
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 1 year ago Abilities.php 1 day ago Blog.php 1 year ago Helper.php 5 months ago Init.php 5 months ago Installer.php 7 months ago MySQL.php 1 year ago UI.php 4 months ago Update.php 1 year ago Wordpress.php 1 day ago index.html 1 year ago web.config 1 year ago
Installer.php
126 lines
1 <?php
2
3 namespace JetBackup\Wordpress;
4
5 use JetBackup\Alert\Alert;
6 use JetBackup\Config\Config;
7 use JetBackup\Crontab\Crontab;
8 use JetBackup\Destination\Destination;
9 use JetBackup\Exception\DBException;
10 use JetBackup\Exception\QueueException;
11 use JetBackup\Factory;
12 use JetBackup\JetBackup;
13 use Plugin_Upgrader;
14 use SleekDB\Exceptions\InvalidArgumentException;
15 use SleekDB\Exceptions\IOException;
16
17 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
18
19 class Installer {
20
21 private function __construct() {} // only static method
22
23 public static function install(): void {
24
25 try {
26
27 if (!class_exists('PDO')) {
28 throw new \Exception(
29 __('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')
30 );
31 }
32
33 if (version_compare(PHP_VERSION, JetBackup::MINIMUM_PHP_VERSION, '<')) {
34 throw new \Exception(
35 sprintf(
36 __('PHP version %s or higher is required. Current version: %s', 'text-domain'),
37 JetBackup::MINIMUM_PHP_VERSION,
38 PHP_VERSION
39 )
40 );
41 }
42
43 if (version_compare(Wordpress::getVersion(), JetBackup::MINIMUM_WP_VERSION, '<')) {
44 throw new \Exception(
45 sprintf(
46 __('WordPress version %s or higher is required. Current version: %s', 'text-domain'),
47 JetBackup::MINIMUM_WP_VERSION,
48 Wordpress::getVersion()
49 )
50 );
51 }
52
53 $plugins = Wordpress::getPlugins();
54 foreach (JetBackup::PLUGIN_CONFLICTS as $plugin) {
55 if (!isset($plugins[$plugin]) || !Wordpress::isPluginActive($plugin)) continue;
56
57 throw new \Exception(
58 sprintf(
59 __('Conflicting plugin detected: %s. Using this plugin alongside JetBackup may cause unexpected behavior. Please disable it before activating JetBackup.', 'text-domain'),
60 $plugins[$plugin]['Name']
61 )
62 );
63 }
64
65 } catch (\Exception $e) {
66 wp_die(
67 sprintf(__('This plugin cannot be activated. %s', 'text-domain'), $e->getMessage()),
68 __('Plugin Activation Error', 'text-domain'),
69 ['back_link' => true]
70 );
71 }
72 }
73
74
75 public static function uninstall():void {
76 Wordpress::deleteOption(Config::WP_DB_CONFIG_PREFIX);
77 $cron = new Crontab();
78 $cron->removeCrontab();
79 }
80
81 public static function deactivate():void {
82 Wordpress::deleteOption(Config::WP_DB_CONFIG_PREFIX);
83 $cron = new Crontab();
84 $cron->removeCrontab();
85 }
86
87 public static function update($upgrader):void {
88
89 if (
90 !isset($upgrader->new_plugin_data) ||
91 !is_array($upgrader->new_plugin_data) ||
92 !isset($upgrader->new_plugin_data['Name']) ||
93 $upgrader->new_plugin_data['Name'] != JetBackup::PLUGIN_EXT_NAME
94 ) {
95 return;
96 }
97
98
99 $config = Factory::getConfig();
100
101 /*
102 // PLACEHOLDER - in case we need changes between versions, this is an example
103
104 $current_version = $config->getCurrentVersion();
105 if(!$current_version || version_compare($current_version, '3.1', '<')) {
106
107 try {
108
109
110 } catch (\Exception $e) {
111 Alert::add(
112 "JetBackup encountered an error during the update process",
113 "Error: " . $e->getMessage(),
114 Alert::LEVEL_WARNING
115 );
116 return;
117 }
118
119 }
120 */
121
122 $config->setCurrentVersion(JetBackup::VERSION);
123 $config->save();
124 }
125 }
126