-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.php
83 lines (72 loc) · 1.76 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* WP Sitemaps Manager uninstallation.
*
* @package WP Sitemaps Manager
*
* @since 0.1
*/
namespace XMLSitemapsManager;
// Exit if uninstall not called from WordPress.
defined( '\WP_UNINSTALL_PLUGIN' ) || exit();
// Check if it is a multisite and not a large one.
if ( \is_multisite() ) {
if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
\error_log( 'Clearing XML Sitemaps Manager settings from each site before uninstall:' );
}
if ( wp_is_large_network() ) {
if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
\error_log( 'Aborting multisite uninstall. Too many sites in your network.' );
}
uninstall();
return;
}
$_ids = get_sites(
array(
'fields' => 'ids',
'number' => -1,
)
); // TEST number = -1..1000.
foreach ( $_ids as $_id ) {
\switch_to_blog( $_id );
uninstall( $_id );
\restore_current_blog();
}
} else {
uninstall();
}
/**
* Remove plugin data.
*
* @since 0.1
*
* @param int $_id Blog ID.
*/
function uninstall( $_id = false ) {
/**
* Remove metadata.
*/
// Terms meta.
delete_metadata( 'term', 0, 'term_modified_gmt', '', true );
// User meta.
delete_metadata( 'user', 0, 'user_modified_gmt', '', true );
// TODO: add Polylang metadata removal.
/**
* Remove plugin settings.
*/
\delete_option( 'xmlsm_version' );
\delete_option( 'xmlsm_sitemaps_enabled' );
\delete_option( 'xmlsm_sitemaps_fixes' );
\delete_option( 'xmlsm_max_urls' );
\delete_option( 'xmlsm_lastmod' );
\delete_option( 'xmlsm_sitemap_providers' );
\delete_option( 'xmlsm_disabled_subtypes' );
// Kilroy was here.
if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
if ( $_id ) {
\error_log( 'XML Sitemaps Manager settings cleared for blog ID:' . $_id );
} else {
\error_log( 'XML Sitemaps Manager settings cleared on uninstall.' );
}
}
}