-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.php
68 lines (56 loc) · 1.21 KB
/
uninstall.php
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
<?php
/**
* Uninstall.
*
* @since 1.0.0
*
* @package Perform
* @subpackage Uninstall
* @author Mehul Gohil
*/
// Bailout, if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Process Uninstall.
*
* @since 1.0.0
*/
function perform_uninstall() {
$setting_types = array(
'perform_common',
'perform_ssl',
'perform_cdn',
'perform_woocommerce',
'perform_advanced',
'perform_import_export',
'perform_support'
);
$remove_data_on_uninstall = perform_get_option( 'remove_data_on_uninstall', 'perform_advanced' );
if ( $remove_data_on_uninstall ) {
if ( is_multisite() ) {
// Get sites list.
$sites = array_map(
'get_object_vars',
get_sites( array(
'deleted' => 0
) )
);
// Loop through each site and delete all the setting types.
if ( is_array( $sites ) && count( $sites ) > 0 ) {
foreach ( $sites as $site ) {
foreach ( $setting_types as $option ) {
delete_blog_option( $site['blog_id'], $option );
}
}
}
} else {
// Loop through the setting types to delete.
foreach ( $setting_types as $option ) {
delete_option( $option );
}
}
}
}
register_uninstall_hook( PERFORM_PLUGIN_FILE, 'perform_uninstall' );