-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
47 lines (39 loc) · 1.11 KB
/
Copy pathuninstall.php
File metadata and controls
47 lines (39 loc) · 1.11 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
<?php
/**
* Uninstall routine — removes all WatchSpire data.
*
* @package WatchSpire
*/
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
global $wpdb;
$tables = array(
'checks',
'changelog',
'submissions',
'crawlers',
'alerts',
'errors',
'links',
);
foreach ( $tables as $table ) {
$full_name = $wpdb->prefix . 'watchspire_' . $table;
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$wpdb->query( "DROP TABLE IF EXISTS `{$full_name}`" );
}
$options = $wpdb->get_col(
$wpdb->prepare(
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s",
$wpdb->esc_like( 'watchspire_' ) . '%'
)
);
foreach ( $options as $option_name ) {
delete_option( $option_name );
}
// Transients.
$wpdb->query(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_watchspire\_%' OR option_name LIKE '\_transient\_timeout\_watchspire\_%'"
);
// Scheduled Action Scheduler actions belonging to WatchSpire, if the library left rows behind.
if ( function_exists( 'as_unschedule_all_actions' ) ) {
as_unschedule_all_actions( '', array(), 'watchspire' );
}