-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
74 lines (62 loc) · 1.67 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Trigger this file on Plugin uninstall
*
* @package talentlms-wordpress
*/
use TalentlmsIntegration\Utils;
if (! defined('WP_UNINSTALL_PLUGIN')) {
die;
}
function tlms_uninstall()
{
tlms_deleteOptions();
tlms_deleteWPPages();
Utils::tlms_deleteWoocomerceProducts();
tlms_dropDB();
}
function tlms_deleteOptions()
{
delete_option('tlms-domain');
delete_option('tlms-apikey');
delete_option('tlms-woocommerce-active');
}
function tlms_deleteWPPages()
{
tlms_removeCoursesPage();
tlms_removeSignupPage();
}
function tlms_removeCoursesPage()
{
global $wpdb;
$the_page_title = get_option('tlms_courses_page_title');
$the_page_name = get_option('tlms_courses_page_name');
$the_page_id = get_option('tlms_courses_page_id');
if ($the_page_id) {
wp_delete_post($the_page_id);
}
delete_option('tlms_courses_page_title');
delete_option('tlms_courses_page_name');
delete_option('tlms_courses_page_id');
}
function tlms_removeSignupPage()
{
global $wpdb;
$the_page_title = get_option('tlms_signup_page_title');
$the_page_name = get_option('tlms_signup_page_name');
$the_page_id = get_option('tlms_signup_page_id');
if ($the_page_id) {
wp_delete_post($the_page_id);
}
delete_option('tlms_signup_page_title');
delete_option('tlms_signup_page_name');
delete_option('tlms_signup_page_id');
}
function tlms_dropDB()
{
global $wpdb;
$wpdb->query('DROP TABLE ' . TLMS_COURSES_TABLE);
$wpdb->query('DROP TABLE ' . TLMS_CATEGORIES_TABLE);
$wpdb->query('DROP TABLE ' . TLMS_PRODUCTS_TABLE);
$wpdb->query('DROP TABLE ' . TLMS_PRODUCTS_CATEGORIES_TABLE);
}