-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
48 lines (40 loc) · 931 Bytes
/
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
/**
* Settings class.
*
* @package Mihdan\ReCrawler
*/
namespace Mihdan\ReCrawler;
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
global $wpdb;
$options = [
'recrawler_general',
'recrawler_index_now',
'recrawler_bing_webmaster',
'recrawler_google_webmaster',
'recrawler_yandex_webmaster',
'recrawler_logs',
'recrawler_version',
];
if ( is_multisite() ) {
// Delete settings.
foreach( $options as $option ) {
delete_site_option( $option );
}
// Delete Log tables.
$sites = get_sites( [ 'fields' => 'ids' ] );
foreach ( $sites as $site_id ) {
switch_to_blog( $site_id );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}recrawler_log" ); // phpcs:ignore
restore_current_blog();
}
} else {
// Delete settings.
foreach( $options as $option ) {
delete_option( $option );
}
// Delete Log table.
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}recrawler_log" ); // phpcs:ignore
}