-
Notifications
You must be signed in to change notification settings - Fork 23
/
uninstall.php
48 lines (39 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
<?php
/**
* Sensei Uninstall
*
* Uninstalls the plugin and associated data.
*
* @package Extension
* @author Automattic
* @since 2.3.0
*
* @var string $plugin Plugin name being passed to `uninstall_plugin()`.
*/
// phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit();
}
if ( class_exists( 'WooThemes_Sensei_Certificates' ) ) {
// Another instance of Sensei Certificates is installed and activated on the current site or network.
return;
}
require dirname( __FILE__ ) . '/woothemes-sensei-certificates.php';
require dirname( __FILE__ ) . '/classes/class-sensei-certificate-data-cleaner.php';
// Cleanup all data.
if ( ! is_multisite() ) {
if ( Sensei_Certificate_Data_Cleaner::should_do_cleanup() ) {
Sensei_Certificate_Data_Cleaner::cleanup_all();
}
} else {
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$original_blog_id = get_current_blog_id();
foreach ( $blog_ids as $_blog_id ) {
switch_to_blog( $_blog_id );
if ( Sensei_Certificate_Data_Cleaner::should_do_cleanup() ) {
Sensei_Certificate_Data_Cleaner::cleanup_all();
}
}
switch_to_blog( $original_blog_id );
}