-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.php
More file actions
39 lines (31 loc) · 1.13 KB
/
Copy pathuninstall.php
File metadata and controls
39 lines (31 loc) · 1.13 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
<?php
/**
* Fired when the plugin is uninstalled.
*
* @package WooCommerce_WhatsApp_Order_Alerts
*/
// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* Process deletion of plugin data if option is enabled.
*/
function wwoa_uninstall_plugin_data() {
$settings = get_option( 'wwoa_settings', array() );
// Check if the delete data on uninstall option is enabled
if ( isset( $settings['delete_data_on_uninstall'] ) && 'yes' === $settings['delete_data_on_uninstall'] ) {
global $wpdb;
// 1. Drop custom table
$table_name = $wpdb->prefix . 'wwoa_logs';
$wpdb->query( "DROP TABLE IF EXISTS {$table_name}" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
// 2. Delete main settings option
delete_option( 'wwoa_settings' );
delete_option( 'wwoa_db_version' );
}
// Always clear scheduled actions registered by this plugin
if ( function_exists( 'as_unschedule_all_actions' ) ) {
as_unschedule_all_actions( '', array(), 'wwoa' );
}
}
wwoa_uninstall_plugin_data();