-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcas_uninstall.php
More file actions
39 lines (33 loc) · 1.03 KB
/
cas_uninstall.php
File metadata and controls
39 lines (33 loc) · 1.03 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
/**
* @package Content Aware Sidebars
* @author Joachim Jensen <joachim@dev.institute>
* @license GPLv3
* @copyright 2024 by Joachim Jensen
*/
defined('ABSPATH') || exit;
if (!(defined('WP_UNINSTALL_PLUGIN') || defined('WP_FS__UNINSTALL_MODE'))) {
exit;
}
global $wpdb;
// Remove db version
delete_option('cas_db_version');
delete_option('cas_pro');
//Remove all sidebars, groups, meta and terms.
$sidebars = get_posts([
'post_type' => 'sidebar',
'posts_per_page' => -1
]);
foreach ($sidebars as $sidebar) {
$groups = get_posts([
'post_parent' => $sidebar->ID,
'post_type' => 'condition_group',
'posts_per_page' => -1
]);
foreach ($groups as $group) {
wp_delete_post($group->ID, true);
}
wp_delete_post($sidebar->ID, true);
}
// Remove user meta
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN('metaboxhidden_sidebar','closedpostboxes_sidebar','managesidebarcolumnshidden','{$wpdb->prefix}_ca_cas_tour')");