forked from JustinSainton/AffiliateWP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
47 lines (36 loc) · 1.58 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
<?php
/**
* Uninstall AffiliateWP
*
* @package AffiliateWP
* @subpackage Uninstall
* @copyright Copyright (c) 2014, Pippin Williamson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
// Exit if accessed directly
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit;
// Load AffiliateWP file
include_once( 'affiliate-wp.php' );
global $wpdb, $wp_roles;
$affiliate_wp_settings = new Affiliate_WP_Settings;
if( $affiliate_wp_settings->get( 'uninstall_on_delete' ) ) {
// Remove the affiliate area page
wp_delete_post( $affiliate_wp_settings->get( 'affiliates_page' ) );
// Remove all plugin settings.
delete_option( 'affwp_settings' );
// Remove other options.
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'affwp\_%';" );
// Remove all capabilities and roles
$caps = new Affiliate_WP_Capabilities;
$caps->remove_caps();
// Remove all database tables
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_affiliates" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_affiliatemeta" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_creatives" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_payouts" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_referrals" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_rest_consumers" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_visits" );
$wpdb->query( "DROP VIEW " . $wpdb->prefix . "affiliate_wp_campaigns" );
}