-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
58 lines (51 loc) · 2.08 KB
/
Copy pathuninstall.php
File metadata and controls
58 lines (51 loc) · 2.08 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
<?php
/**
* Uninstall routine. Removes every trace of the plugin.
*
* @package AI_Malware_Scanner
*/
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
delete_option( 'wp_sentinel_settings' );
delete_option( 'wp_sentinel_access_log' );
delete_option( 'wp_sentinel_scan_results' );
delete_transient( 'wp_sentinel_file_index' );
global $wpdb;
/*
* Cached checksum manifests and rate-limit counters are transients whose names
* are generated at runtime (they embed a plugin slug or a hashed IP), so they
* cannot be enumerated up front.
*
* The names are collected first and removed with delete_transient() rather than
* being deleted straight out of the options table. Going through the API keeps
* any persistent object cache in step; a raw DELETE would leave a Redis or
* Memcached backend serving values whose rows no longer exist. The matching
* _transient_timeout_ rows are removed by delete_transient() as well.
*/
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time uninstall cleanup of runtime-named transients. No Core API can list options by prefix, and caching a result set that is about to be deleted would be pointless.
$transients = $wpdb->get_col(
$wpdb->prepare(
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s",
$wpdb->esc_like( '_transient_wp_sentinel_' ) . '%'
)
);
if ( $transients ) {
foreach ( $transients as $option_name ) {
delete_transient( substr( $option_name, strlen( '_transient_' ) ) );
}
}
/*
* Checksum manifests are stored as site transients, which live in a separate
* table on multisite.
*/
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- See above; one-time uninstall cleanup.
$site_transients = $wpdb->get_col(
$wpdb->prepare(
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s",
$wpdb->esc_like( '_site_transient_wp_sentinel_' ) . '%'
)
);
if ( $site_transients ) {
foreach ( $site_transients as $option_name ) {
delete_site_transient( substr( $option_name, strlen( '_site_transient_' ) ) );
}
}