-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
43 lines (37 loc) · 1.3 KB
/
Copy pathuninstall.php
File metadata and controls
43 lines (37 loc) · 1.3 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
<?php
/**
* Runs only when the user clicks "Delete" in wp-admin → Plugins.
* Custom tables are intentionally kept to prevent data loss on accidental uninstall.
* To fully wipe data, admin must use Settings → Advanced → Erase all data.
*/
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
// Uninstall script variables are file-scoped and cannot collide at runtime.
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
// Remove plugin options.
$recfw_options = [
'recfw_settings',
'recfw_version',
'recfw_db_version',
'recfw_activation_date',
'recfw_license_key',
'recfw_license_status',
'recfw_license_jwt',
'recfw_monthly_rma_count',
'recfw_monthly_rma_month',
];
foreach ( $recfw_options as $recfw_option ) {
delete_option( $recfw_option );
}
// Remove scheduled events.
wp_clear_scheduled_hook( 'recfw_hourly_sync' );
wp_clear_scheduled_hook( 'recfw_daily_maintenance' );
// Remove capabilities from roles.
foreach ( [ 'administrator', 'shop_manager' ] as $recfw_role_name ) {
$recfw_role = get_role( $recfw_role_name );
if ( $recfw_role ) {
$recfw_role->remove_cap( 'manage_recfw' );
$recfw_role->remove_cap( 'view_recfw_reports' );
}
}
// NOTE: Custom tables (_recfw_rmas etc.) are NOT dropped here.
// Use Settings → Advanced → "Delete all data" to drop tables.