PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.2
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.2
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 / class-charitable-uninstall.php

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

94 lines 2.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 * @version 1.0.0
10 * @author Eric Daams
11 * @copyright Copyright (c) 2018, Studio 164a
12 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
13 */
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) { exit; }
16
17 if ( ! class_exists( 'Charitable_Uninstall' ) ) :
18
19 /**
20 * Charitable_Uninstall
21 *
22 * @since 1.0.0
23 */
24 class Charitable_Uninstall {
25
26 /**
27 * Uninstall the plugin.
28 *
29 * @since 1.0.0
30 */
31 public function __construct() {
32 if ( charitable()->is_deactivation() && charitable_get_option( 'delete_data_on_uninstall' ) ) {
33
34 $this->remove_caps();
35 $this->remove_post_data();
36 $this->remove_tables();
37
38 do_action( 'charitable_uninstall' );
39 }
40 }
41
42 /**
43 * Remove plugin-specific roles.
44 *
45 * @since 1.0.0
46 *
47 * @return void
48 */
49 private function remove_caps() {
50 $roles = new Charitable_Roles();
51 $roles->remove_caps();
52 }
53
54 /**
55 * Remove post objects created by Charitable.
56 *
57 * @since 1.0.0
58 *
59 * @return void
60 */
61 private function remove_post_data() {
62 foreach ( array( 'campaign', 'donation' ) as $post_type ) {
63 $posts = get_posts( array(
64 'posts_per_page' => -1,
65 'post_type' => $post_type
66 ) );
67
68 foreach ( $posts as $post ) {
69 wp_delete_post( $post->ID, true );
70 }
71 }
72 }
73
74 /**
75 * Remove the custom tables added by Charitable.
76 *
77 * @since 1.0.0
78 *
79 * @return void
80 */
81 private function remove_tables() {
82 global $wpdb;
83
84 $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "charitable_campaign_donations" );
85 $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "charitable_donors" );
86 $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "charitable_benefactors" );
87
88 delete_option( $wpdb->prefix . 'charitable_campaign_donations_db_version' );
89 delete_option( $wpdb->prefix . 'charitable_donors_db_version' );
90 delete_option( $wpdb->prefix . 'charitable_benefactors_db_version' );
91 }
92 }
93
94 endif;