-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathuninstall.php
executable file
·39 lines (33 loc) · 1.18 KB
/
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
<?php
/**
* WooCommerce wallet Uninstall
*
* Uninstalling WooCommerce wallet product, tables, and options.
*
* @author Subrata Mal
* @version 1.0.1
*
* @package StandaleneTech
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
global $wpdb, $wp_version;
// Remove rechargable product.
wp_delete_post( get_option( '_woo_wallet_recharge_product' ), true );
delete_option( '_woo_wallet_recharge_product' );
/*
* Only remove ALL plugins data if WALLET_REMOVE_ALL_DATA constant is set to true in user's
* wp-config.php. This is to prevent data loss when deleting the plugin from the backend
* and to ensure only the site owner can perform this action.
*/
if ( defined( 'WALLET_REMOVE_ALL_DATA' ) && true === WALLET_REMOVE_ALL_DATA ) {
// Tables.
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}woo_wallet_transactions" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}woo_wallet_transaction_meta" );
// Delete options.
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wallet\_%';" );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_woo_wallet\_%';" );
// Clear any cached data that has been removed.
wp_cache_flush();
}