-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
45 lines (39 loc) · 1.21 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
40
41
42
43
44
45
<?php
defined('ABSPATH') or die('No script kiddies please!');
/**
* TSEO PRO Uninstall
*
* Uninstalling TseoIndexing deletes tables and options.
*
* @package TSEOIndexing
* @version 1.0.0
*/
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
$options_to_delete = array(
'tseoindexing_options_key',
'tseoindexing_merchant_center_id',
'tseoindexing_merchant_center_credentials',
'tseoindexing_merchant_send_automatically',
'tseoindexing_selected_products',
'tseoindexing_openai_api_key'
);
// Check if the delete_option and delete_site_option functions exist
if (function_exists('delete_option') && function_exists('delete_site_option')) {
foreach ($options_to_delete as $option) {
delete_option($option);
delete_site_option($option);
}
} else {
error_log('Error: The delete_option or delete_site_option functions do not exist.');
}
// Delete the custom table
global $wpdb;
$table_name = $wpdb->prefix . 'tseo_indexing_links';
if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name) {
$sql = "DROP TABLE IF EXISTS $table_name";
$wpdb->query($sql);
} else {
error_log("Error: The table $table_name does not exist or has already been deleted.");
}