forked from strangerstudios/paid-memberships-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
39 lines (33 loc) · 939 Bytes
/
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
/**
* Leave no trace...
* Use this file to remove all elements added by plugin, including database table
*/
// exit if uninstall/delete not called
if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN'))
exit();
// otherwise remove db tables
global $wpdb;
$tables = array(
'pmpro_discount_codes',
'pmpro_discount_codes_levels',
'pmpro_discount_codes_uses',
'pmpro_memberships_categories',
'pmpro_memberships_pages',
'pmpro_memberships_users',
'pmpro_membership_levels',
'pmpro_membership_orders'
);
foreach($tables as $table){
$delete_table = $wpdb->prefix . $table;
// setup sql query
$sql = "DROP TABLE `$delete_table`";
// run the query
$wpdb->query($sql);
}
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
//delete options
global $wpdb;
$sqlQuery = "DELETE FROM $wpdb->options WHERE option_name LIKE 'pmpro_%'";
$wpdb->query($sqlQuery);