-
Notifications
You must be signed in to change notification settings - Fork 2
/
uninstall.php
63 lines (54 loc) · 1.24 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
<?php
/**
* Uninstall plugin.
*
* @package Auto Listings.
*/
// Exit if accessed directly.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Load Auto_Listings file.
include_once( 'auto-listings.php' );
global $wpdb, $wp_roles;
$remove = auto_listings_option( 'delete_data' );
if ( 'yes' !== $remove ) {
return;
}
$auto_listings_post_types = [ 'auto-listing', 'listing-enquiry' ];
foreach ( $auto_listings_post_types as $auto_listings_post_type ) {
$items = get_posts(
[
'post_type' => $auto_listings_post_type,
'numberposts' => - 1,
'post_status' => [
'publish',
'pending',
'draft',
'auto-draft',
'future',
'private',
'inherit',
'trash',
],
'fields' => 'ids',
]
);
if ( $items ) {
foreach ( $items as $item ) {
wp_delete_post( $item, true );
}
}
}
/** Delete all the Plugin Options */
delete_option( 'auto_listings_options' );
delete_option( 'auto_listings_version' );
delete_option( 'auto_listings_version_upgraded_from' );
/** Delete Capabilities */
$roles = new AutoListings\Roles();
$roles->remove_caps();
/** Delete the Roles */
$auto_listings_roles = [ 'auto_listings_seller' ];
foreach ( $auto_listings_roles as $auto_listings_role ) {
remove_role( $auto_listings_role );
}