PluginProbe
Boxzilla – WordPress Popup Builder / trunk
Boxzilla – WordPress Popup Builder vtrunk
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
boxzilla / uninstall.php

uninstall.php in Boxzilla – WordPress Popup Builder trunk, at uninstall.php

57 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Boxzilla Uninstall
5 *
6 * Fired when the plugin is deleted (not just deactivated).
7 * Cleans up all data stored by the plugin.
8 */
9
10 // Exit if not called from WordPress uninstall process
11 defined('WP_UNINSTALL_PLUGIN') or exit;
12
13 // 1. Delete all boxzilla-box posts (including revisions and post meta)
14 $post_ids = get_posts([
15 'post_type' => 'boxzilla-box',
16 'post_status' => 'any',
17 'posts_per_page' => -1,
18 'fields' => 'ids',
19 'no_found_rows' => true,
20 ]);
21
22 foreach ($post_ids as $post_id) {
23 wp_delete_post($post_id, true);
24 }
25
26 // 2. Delete any orphaned post meta (in case wp_delete_post missed some)
27 global $wpdb;
28 $wpdb->delete($wpdb->postmeta, ['meta_key' => 'boxzilla_options']);
29
30 // 3. Delete options
31 delete_option('boxzilla_settings');
32 delete_option('boxzilla_rules');
33 delete_option('boxzilla_version');
34 delete_option('boxzilla_license');
35
36 // 4. Delete transients
37 delete_transient('boxzilla_remote_extensions');
38 delete_transient('boxzilla_request_failed');
39
40 // 5. Delete user meta for review notice dismissal
41 $wpdb->delete($wpdb->usermeta, ['meta_key' => '_boxzilla_review_notice_dismissed']);
42
43 // 6. Remove custom capabilities from administrator role
44 $admins = get_role('administrator');
45 if ($admins instanceof WP_Role) {
46 $admins->remove_cap('edit_box');
47 $admins->remove_cap('edit_boxes');
48 $admins->remove_cap('edit_other_boxes');
49 $admins->remove_cap('publish_boxes');
50 $admins->remove_cap('read_box');
51 $admins->remove_cap('read_private_box');
52 $admins->remove_cap('delete_box');
53 }
54
55 // 7. Unschedule cron event
56 wp_clear_scheduled_hook('boxzilla_check_license_status');
57