forked from awesomemotive/easy-digital-downloads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
executable file
·69 lines (58 loc) · 1.95 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Uninstall Easy Digital Downloads
*
* @package EDD
* @subpackage Uninstall
* @copyright Copyright (c) 2013, Pippin Williamson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.4.3
*/
// Exit if accessed directly
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit;
// Load EDD file
include_once( 'easy-digital-downloads.php' );
global $wpdb, $edd_options, $wp_roles;
/** Delete All the Custom Post Types */
$edd_post_types = array( 'download', 'edd_payment', 'edd_discount', 'edd_log' );
foreach ( $edd_post_types as $post_type ) {
$items = get_posts( array( 'post_type' => $post_type, 'numberposts' => -1, 'fields' => 'ids' ) );
if ( $items ) {
foreach ( $items as $item ) {
wp_delete_post( $item, true);
}
}
}
/** Delete All the Taxonomies */
$edd_taxonomies = array( 'download_tag', 'download_category', 'edd_log_type' );
foreach ( $edd_taxonomies as $taxonomy ) {
global $wp_taxonomies;
$terms = get_terms( $taxonomy );
if ( $terms ) {
foreach ( $terms as $term ) {
wp_delete_term( $term->term_id, $taxonomy );
}
}
unset( $wp_taxonomies[ $taxonomy ] );
}
/** Delete the Plugin Pages */
if ( isset( $edd_options['purchase_page'] ) )
wp_delete_post( $edd_options['purchase_page'], true );
if ( isset( $edd_options['success_page'] ) )
wp_delete_post( $edd_options['success_page'], true );
if ( isset( $edd_options['failure_page'] ) )
wp_delete_post( $edd_options['failure_page'], true );
/** Delete all the Plugin Options */
delete_option( 'edd_settings_general' );
delete_option( 'edd_settings_gateways' );
delete_option( 'edd_settings_emails' );
delete_option( 'edd_settings_styles' );
delete_option( 'edd_settings_taxes' );
delete_option( 'edd_settings_misc' );
/** Delete Capabilities */
EDD()->roles->remove_caps();
/** Delete the Roles */
$edd_roles = array( 'shop_manager', 'shop_accountant', 'shop_worker', 'shop_vendor' );
foreach ( $edd_roles as $role ) {
remove_role( $role );
}