PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.10.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.10.0
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 1 year ago Backup 1 year ago Basic 1 year ago Core 1 year ago Framework 1 year ago Frontend 1 year ago Notifications 1 year ago Staging 1 year ago assets 1 year ago languages 1 year ago resources 1 year ago vendor_wpstg 1 year ago views 1 year ago CONTRIBUTING.md 1 year ago Deactivate.php 2 years ago README.md 1 year ago SECURITY.md 2 years ago autoloader.php 3 years ago bootstrap.php 1 year ago constantsFree.php 1 year ago freeBootstrap.php 2 years ago install.php 1 year ago opcacheBootstrap.php 1 year ago readme.txt 1 year ago runtimeRequirements.php 1 year ago uninstall.php 1 year ago wp-staging-error-handler.php 1 year ago wp-staging.php 1 year ago
Deactivate.php
105 lines
1 <?php
2
3 namespace WPStaging;
4
5 /**
6 * Actions to perform when we deactivate WP Staging Plugin
7 */
8 class Deactivate
9 {
10 /**
11 * @var string
12 */
13 private $currentPluginFile;
14
15 /**
16 * @param string $currentPluginFile
17 */
18 public function __construct($currentPluginFile)
19 {
20 $this->currentPluginFile = $currentPluginFile;
21
22 // Early bail
23 // This filter hook is for internal use only
24 if (apply_filters('wpstg.deactivation_hook.skip_mu_delete', false)) {
25 return;
26 }
27
28 // Only delete MU plugin when no other wp staging plugin is activated
29 if (!$this->isOtherWPStagingPluginActivated()) {
30 $this->deleteMuPlugin();
31 }
32
33 $this->deleteBackupSchedulesFromCron();
34 $this->deleteOtherCron();
35 }
36
37 /**
38 * Check if any other WP Staging Plugin is activated other than current one
39 *
40 * @return boolean
41 */
42 private function isOtherWPStagingPluginActivated()
43 {
44 foreach (wp_get_active_and_valid_plugins() as $activePlugin) {
45 if ($activePlugin === $this->currentPluginFile) {
46 continue;
47 }
48
49 if (strpos($activePlugin, 'wp-staging.php') !== false || strpos($activePlugin, 'wp-staging-pro.php') !== false) {
50 return true;
51 }
52 }
53
54 return false;
55 }
56
57 /**
58 * delete MuPlugin
59 */
60 private function deleteMuPlugin()
61 {
62 $muDir = (defined('WPMU_PLUGIN_DIR')) ? WPMU_PLUGIN_DIR : trailingslashit(WP_CONTENT_DIR) . 'mu-plugins';
63 $dest = trailingslashit($muDir) . 'wp-staging-optimizer.php';
64
65 if (file_exists($dest) && !unlink($dest)) {
66 return false;
67 }
68
69 return true;
70 }
71
72 protected function deleteBackupSchedulesFromCron()
73 {
74 if (!file_exists(__DIR__ . '/Backup/BackupScheduler.php')) {
75 return;
76 }
77
78 if (!class_exists('\WPStaging\Backup\BackupScheduler')) {
79 require_once __DIR__ . '/Backup/BackupScheduler.php';
80 }
81
82 \WPStaging\Backup\BackupScheduler::removeBackupSchedulesFromCron();
83 }
84
85 /**
86 * delete Other Cron
87 */
88 private function deleteOtherCron()
89 {
90 $hooks = [
91 'wpstg_q_ajax_support_feature_detection',
92 'wpstg_queue_maintain',
93 'wpstg_queue_process',
94 'wpstg_weekly_event',
95 'wpstg_daily_event'
96 ];
97
98 foreach ($hooks as $hook) {
99 if (wp_get_schedule($hook)) {
100 wp_clear_scheduled_hook($hook);
101 }
102 }
103 }
104 }
105