PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / trunk
WP STAGING – WordPress Backups, Restore, Migration & Clone vtrunk
4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Deactivate.php
wp-staging Last commit date
Backend 2 days ago Backup 2 days ago Basic 2 days ago Component 2 days ago Core 2 days ago Framework 2 days ago Frontend 2 days ago Notifications 2 days ago Staging 2 days ago assets 2 days ago languages 2 days ago resources 2 days ago vendor_wpstg 2 days ago views 2 days ago CONTRIBUTING.md 2 years ago Deactivate.php 2 days ago README.md 5 months ago SECURITY.md 3 weeks ago autoloader.php 2 days ago bootstrap.php 2 days ago commonBootstrap.php 2 days ago constantsFree.php 2 days ago freeBootstrap.php 2 days ago install.php 2 days ago opcacheBootstrap.php 2 days ago readme.txt 2 days ago runtimeRequirements.php 2 days ago uninstall.php 2 days ago wp-staging-error-handler.php 2 days ago wp-staging.php 2 days ago
Deactivate.php
123 lines
1 <?php
2
3 namespace WPStaging;
4
5 use WPStaging\Core\Cron\Cron;
6 use WPStaging\Framework\Analytics\Actions\PluginLifecycle;
7 use WPStaging\Framework\BackgroundProcessing\BackgroundProcessingServiceProvider;
8 use WPStaging\Framework\BackgroundProcessing\FeatureDetection;
9 use WPStaging\Framework\BackgroundProcessing\QueueProcessor;
10
11
12
13
14 class Deactivate
15 {
16
17
18
19 private $currentPluginFile;
20
21
22
23
24 public function __construct($currentPluginFile)
25 {
26 $this->currentPluginFile = $currentPluginFile;
27
28
29
30 if (apply_filters('wpstg.deactivation_hook.skip_mu_delete', false)) {
31 return;
32 }
33
34
35
36
37
38
39 PluginLifecycle::recordDeactivation();
40
41
42 if (!$this->isOtherWPStagingPluginActivated()) {
43 $this->deleteMuPlugin();
44 }
45
46 $this->deleteBackupSchedulesFromCron();
47 $this->deleteOtherCron();
48 }
49
50
51
52
53
54
55 private function isOtherWPStagingPluginActivated()
56 {
57 foreach (wp_get_active_and_valid_plugins() as $activePlugin) {
58 if ($activePlugin === $this->currentPluginFile) {
59 continue;
60 }
61
62 if (strpos($activePlugin, 'wp-staging.php') !== false || strpos($activePlugin, 'wp-staging-pro.php') !== false) {
63 return true;
64 }
65 }
66
67 return false;
68 }
69
70
71
72
73 private function deleteMuPlugin()
74 {
75 $muDir = (defined('WPMU_PLUGIN_DIR')) ? WPMU_PLUGIN_DIR : trailingslashit(WP_CONTENT_DIR) . 'mu-plugins';
76 $dest = trailingslashit($muDir) . 'wp-staging-optimizer.php';
77
78 if (file_exists($dest) && !unlink($dest)) {
79 return false;
80 }
81
82 return true;
83 }
84
85 protected function deleteBackupSchedulesFromCron()
86 {
87 if (!file_exists(__DIR__ . '/Backup/BackupScheduler.php')) {
88 return;
89 }
90
91 if (!class_exists('\WPStaging\Backup\BackupScheduler')) {
92 require_once __DIR__ . '/Backup/BackupScheduler.php';
93 }
94
95
96 if (!class_exists('\WPStaging\Core\Cron\Cron')) {
97 require_once __DIR__ . '/Core/Cron/Cron.php';
98 }
99
100 \WPStaging\Backup\BackupScheduler::removeBackupSchedulesFromCron();
101 }
102
103
104
105
106 private function deleteOtherCron()
107 {
108 $hooks = [
109 FeatureDetection::ACTION_AJAX_SUPPORT_FEATURE_DETECTION,
110 BackgroundProcessingServiceProvider::ACTION_QUEUE_MAINTAIN,
111 QueueProcessor::ACTION_QUEUE_PROCESS,
112 Cron::ACTION_WEEKLY_EVENT,
113 Cron::ACTION_DAILY_EVENT,
114 ];
115
116 foreach ($hooks as $hook) {
117 if (wp_get_schedule($hook)) {
118 wp_clear_scheduled_hook($hook);
119 }
120 }
121 }
122 }
123