-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.php
More file actions
65 lines (56 loc) · 1.48 KB
/
uninstall.php
File metadata and controls
65 lines (56 loc) · 1.48 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
<?php
/**
* Plugin Uninstall Handler.
*
* @since 1.0.0
* @package Perform
* @subpackage Uninstall
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* Handle Perform plugin uninstall process.
*
* @since 1.0.0
*/
function perform_handle_plugin_uninstall() {
$option_keys = array(
'perform_settings',
'perform_common',
'perform_ssl',
'perform_cdn',
'perform_woocommerce',
'perform_advanced',
'perform_import_export',
'perform_support',
'perform_assets_manager_options',
'perform_cache_preload_queue',
'perform_cache_stats',
);
$remove_data_on_uninstall = false;
$current_settings = get_option( 'perform_settings' );
if ( is_array( $current_settings ) && isset( $current_settings['remove_data_on_uninstall'] ) ) {
$remove_data_on_uninstall = ! empty( $current_settings['remove_data_on_uninstall'] );
} elseif ( function_exists( 'perform_get_option' ) ) {
$remove_data_on_uninstall = (bool) perform_get_option( 'remove_data_on_uninstall', 'perform_advanced' );
}
if ( $remove_data_on_uninstall ) {
if ( is_multisite() ) {
$sites = get_sites( array( 'deleted' => 0 ) );
if ( ! empty( $sites ) ) {
foreach ( $sites as $site ) {
foreach ( $option_keys as $option ) {
delete_blog_option( (int) $site->blog_id, $option );
}
}
}
} else {
foreach ( $option_keys as $option ) {
delete_option( $option );
}
}
}
}
// Directly run the uninstall handler without needing constants.
perform_handle_plugin_uninstall();