-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.php
More file actions
121 lines (114 loc) · 3.45 KB
/
uninstall.php
File metadata and controls
121 lines (114 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* Uninstall handler — runs when the plugin is deleted via Plugins > Delete.
*
* Removes all plugin options and clears scheduled cron events.
* Backup files in /wp-content/cloudscale-backups/ are intentionally
* left on disk so that a reinstall or manual restore remains possible.
*/
defined( 'ABSPATH' ) || exit;
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
// Remove all plugin options.
$csbr_options = [
'csbr_loaded_version',
'csbr_schedule_enabled',
'csbr_run_days',
'csbr_run_days_saved',
'csbr_run_hour',
'csbr_run_minute',
'csbr_schedule_components',
'csbr_manual_defaults',
'csbr_retention',
'csbr_backup_prefix',
'csbr_backup_seq',
'csbr_s3_bucket',
'csbr_s3_prefix',
'csbr_s3_key_id',
'csbr_s3_secret_key',
'csbr_s3_region',
'csbr_s3_log',
'csbr_gdrive_remote',
'csbr_gdrive_path',
'csbr_gdrive_log',
'csbr_dropbox_remote',
'csbr_dropbox_path',
'csbr_dropbox_log',
'csbr_dropbox_sync_enabled',
'csbr_dropbox_remote_count',
'csbr_dropbox_history',
'csbr_s3_sync_enabled',
'csbr_gdrive_sync_enabled',
'csbr_s3_remote_count',
'csbr_gdrive_remote_count',
'csbr_ami_sync_enabled',
'csbr_ami_schedule_days',
'csbr_cloud_schedule_enabled',
'csbr_cloud_backup_delay',
'csbr_ami_prefix',
'csbr_ami_reboot',
'csbr_ami_region_override',
'csbr_ami_max',
'csbr_ami_log',
'csbr_ami_run_hour',
'csbr_ami_run_minute',
'csbr_s3_history',
'csbr_gdrive_history',
'csbr_toolbar_button',
'csbr_notify_enabled',
'csbr_notify_email',
'csbr_notify_on',
'csbr_notify_on_rollback',
'csbr_sms_enabled',
'csbr_sms_sid',
'csbr_sms_token',
'csbr_sms_from',
'csbr_sms_to',
'csbr_sms_on_backup',
'csbr_sms_on_rollback',
'csbr_sms_on',
'csbr_ntfy_enabled',
'csbr_ntfy_url',
'csbr_ntfy_on_backup',
'csbr_ntfy_on_rollback',
'csbr_ntfy_on',
'csbr_encrypt_password',
'csbr_auto_repair',
'csbr_verify_log',
];
foreach ( $csbr_options as $csbr_option ) {
delete_option( $csbr_option );
}
// Automatic Crash Recovery options.
$csbr_par_options = [
'csbr_par_monitors',
'csbr_par_history',
'csbr_par_settings',
'csbr_par_watchdog_heartbeat',
'csbr_par_pending_notifications',
];
foreach ( $csbr_par_options as $csbr_option ) {
delete_option( $csbr_option );
}
// Remove PAR fatal-error dropin if we wrote it.
$csbr_dropin = WP_CONTENT_DIR . '/fatal-error-handler.php';
if ( file_exists( $csbr_dropin ) && strpos( file_get_contents( $csbr_dropin ), 'CloudScale-PAR-Dropin' ) !== false ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
wp_delete_file( $csbr_dropin );
}
// Remove PAR state file and watchdog script.
$csbr_par_dir = WP_CONTENT_DIR . '/cloudscale-backups/.plugin-auto-recovery/';
if ( is_dir( $csbr_par_dir ) ) {
$csbr_state_file = $csbr_par_dir . 'state.json';
if ( file_exists( $csbr_state_file ) ) {
wp_delete_file( $csbr_state_file );
}
}
$csbr_watchdog_script = '/usr/local/bin/csbr-par-watchdog.sh';
if ( file_exists( $csbr_watchdog_script ) ) {
wp_delete_file( $csbr_watchdog_script );
}
// Clear scheduled cron events.
wp_clear_scheduled_hook( 'csbr_scheduled_backup' );
wp_clear_scheduled_hook( 'csbr_scheduled_ami_backup' );
wp_clear_scheduled_hook( 'csbr_ami_poll' );
wp_clear_scheduled_hook( 'csbr_s3_retry' );
wp_clear_scheduled_hook( 'csbr_ami_delete_check' );