PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.0
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.0
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / includes / plugin / class-charitable-uninstall.php

class-charitable-uninstall.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.0, at includes/plugin/class-charitable-uninstall.php

124 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Uninstall class.
4 *
5 * The responsibility of this class is to manage the events that need to happen
6 * when the plugin is deactivated.
7 *
8 * @package Charitable/Charitable_Uninstall
9 * @author David Bisset
10 * @copyright Copyright (c) 2023, WP Charitable LLC
11 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
12 * @since 1.0.0
13 * @version 1.6.42
14 */
15
16 // Exit if accessed directly.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 if ( ! class_exists( 'Charitable_Uninstall' ) ) :
22
23 /**
24 * Charitable_Uninstall
25 *
26 * @since 1.0.0
27 */
28 class Charitable_Uninstall {
29
30 /**
31 * Uninstall the plugin.
32 *
33 * @since 1.0.0
34 */
35 public function __construct() {
36 if ( charitable()->is_deactivation() && charitable_get_option( 'delete_data_on_uninstall' ) ) {
37
38 $this->remove_caps();
39 $this->remove_post_data();
40 $this->remove_tables();
41 $this->remove_settings();
42
43 do_action( 'charitable_uninstall' );
44 }
45 }
46
47 /**
48 * Remove plugin-specific roles.
49 *
50 * @since 1.0.0
51 *
52 * @return void
53 */
54 private function remove_caps() {
55 $roles = new Charitable_Roles();
56 $roles->remove_caps();
57 }
58
59 /**
60 * Remove post objects created by Charitable.
61 *
62 * @since 1.0.0
63 *
64 * @global WPDB $wpdb The WordPress database object.
65 * @return void
66 */
67 private function remove_post_data() {
68 global $wpdb;
69
70 $posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type IN ( 'donation', 'campaign' );" );
71
72 foreach ( $posts as $post_id ) {
73 wp_delete_post( $post_id, true );
74 }
75 }
76
77 /**
78 * Remove the custom tables added by Charitable.
79 *
80 * @since 1.0.0
81 *
82 * @global WPDB $wpdb The WordPress database object.
83 * @return void
84 */
85 private function remove_tables() {
86 global $wpdb;
87
88 $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'charitable_campaign_donations' );
89 $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'charitable_donors' );
90 $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'charitable_donormeta' );
91 $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'charitable_benefactors' );
92
93 delete_option( $wpdb->prefix . 'charitable_campaign_donations_db_version' );
94 delete_option( $wpdb->prefix . 'charitable_donors_db_version' );
95 delete_option( $wpdb->prefix . 'charitable_donormeta_db_version' );
96 delete_option( $wpdb->prefix . 'charitable_benefactors_db_version' );
97 }
98
99 /**
100 * Remove any other options added by Charitable.
101 *
102 * @since 1.6.42
103 *
104 * @return void
105 */
106 private function remove_settings() {
107 delete_option( 'charitable_settings' );
108 delete_option( 'charitable_version' );
109 delete_option( 'charitable_upgrade_log' );
110 delete_option( 'charitable_skipped_donations_with_empty_donor_id' );
111
112 delete_transient( 'charitable_notices' );
113 delete_transient( 'charitable_user_dashboard_objects' );
114 delete_transient( 'charitable_custom_styles' );
115
116 /* Stop Charitable from re-adding the notices transient. */
117 if ( function_exists( 'charitable_get_admin_notices' ) ) {
118 remove_action( 'shutdown', array( charitable_get_admin_notices(), 'shutdown' ) );
119 }
120 }
121 }
122
123 endif;
124