-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
70 lines (59 loc) · 1.64 KB
/
uninstall.php
File metadata and controls
70 lines (59 loc) · 1.64 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
<?php
/**
* Fired when the plugin is uninstalled.
*
* Everything in uninstall.php will be executed when the user decides
* to delete the plugin from the WordPress admin.
*
* @since 1.0.0
*
* @package WebberZone\Link_Warnings
*/
// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* Fired when the plugin is uninstalled.
*
* @since 1.0.0
*/
do_action( 'wzlw_uninstall' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
global $wpdb;
if ( is_multisite() ) {
$sites = get_sites( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
array(
'archived' => 0,
'spam' => 0,
'deleted' => 0,
)
);
foreach ( $sites as $site ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
switch_to_blog( (int) $site->blog_id );
wzlw_delete_data();
restore_current_blog();
}
} else {
wzlw_delete_data();
}
/**
* Delete plugin data for the current site.
*
* @since 1.0.0
*/
function wzlw_delete_data() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
// Delete plugin settings.
delete_option( 'wzlw_settings' );
// Delete wizard options.
delete_option( 'wzlw_show_wizard' );
delete_option( 'wzlw_wizard_completed' );
delete_option( 'wzlw_wizard_completed_date' );
delete_option( 'wzlw_wizard_current_step' );
// Delete transients.
delete_transient( 'wzlw_activation_redirect' );
delete_transient( 'wzlw_show_wizard_activation_redirect' );
// Flush rewrite rules.
global $wp_rewrite;
$wp_rewrite->init();
flush_rewrite_rules();
}