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