-
Notifications
You must be signed in to change notification settings - Fork 11
/
uninstall.php
68 lines (54 loc) · 1.82 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
<?php
/**
* PermalinksCustomizer Uninstall
*
* Deletes Settings, Post Permalinks and Taxonomies Permalinks
* on uninstalling the Plugin.
*
* @package PermalinksCustomizer
* @since 2.0.0
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
$args = array(
'public' => true
);
// Delete Plugin Version
delete_option( 'permalinks_customizer_plugin_version' );
// Delete PostType Settings
$post_types = get_post_types( $args, 'objects' );
foreach ( $post_types as $post_type ) {
delete_option( 'permalinks_customizer_' . $post_type->name );
}
// Delete Taxonomy Settings
delete_option( 'permalinks_customizer_taxonomy_settings' );
// Delete meta_keys for posts/pages
delete_post_meta_by_key( 'permalink_customizer' );
delete_post_meta_by_key( 'permalink_customizer_regenerate_status' );
// Delete Category/Tags with Older version style
delete_option( 'permalinks_customizer_table' );
global $wpdb;
// Delete all terms with latest version style
$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'permalink_customizer'" );
// Drop Redirects Table if Exist
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}permalinks_customizer_redirects" );
$get_capability = get_option( 'permalinks_customizer_capabilities', -1 );
if ( -1 !== $get_capability ) {
$capabilities = unserialize( $get_capability );
foreach ( $capabilities as $pc_role => $capability ) {
$role = get_role( $pc_role );
foreach ( $capability as $row ) {
$role->remove_cap( $row );
}
}
}
$role = get_role( 'permalinks_customizer_manager' );
if ( ! empty( $role ) ) {
$role->remove_cap( 'pc_manage_permalinks' );
$role->remove_cap( 'pc_manage_permalink_settings' );
$role->remove_cap( 'pc_manage_permalink_redirects' );
remove_role( 'permalinks_customizer_manager' );
}
// Clear any cached data that has been removed
wp_cache_flush();