-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathuninstall.php
More file actions
54 lines (46 loc) · 1.4 KB
/
Copy pathuninstall.php
File metadata and controls
54 lines (46 loc) · 1.4 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
<?php
/**
* Uninstall script
*
* @license GPL-2.0-or-later
* @package AgenticAdmin
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* Delete the connector rate-limit counters (one option row per user per minute).
*
* @return void
*/
function agentic_admin_delete_rate_limit_counters(): void {
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- One-off cleanup on uninstall.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
$wpdb->esc_like( 'agentic_admin_conn_rl_' ) . '%'
)
);
}
// 1. Single Site Cleanup.
agentic_admin_delete_rate_limit_counters();
delete_option( 'agentic_admin_settings' );
delete_option( 'agentic_admin_model_source' );
delete_option( 'agentic_admin_version' );
delete_transient( 'agentic_admin_cache' );
delete_transient( 'agentic_admin_post_types' );
// 2. Multisite Cleanup.
if ( is_multisite() ) {
$agentic_admin_sites = get_sites();
foreach ( $agentic_admin_sites as $agentic_admin_site ) {
switch_to_blog( $agentic_admin_site->blog_id );
agentic_admin_delete_rate_limit_counters();
delete_option( 'agentic_admin_settings' );
delete_option( 'agentic_admin_model_source' );
delete_option( 'agentic_admin_version' );
delete_transient( 'agentic_admin_cache' );
delete_transient( 'agentic_admin_post_types' );
restore_current_blog();
}
}