-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.php
More file actions
52 lines (42 loc) · 1.26 KB
/
Copy pathuninstall.php
File metadata and controls
52 lines (42 loc) · 1.26 KB
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
<?php
/**
* Uninstall script for Post Poster plugin
*
* @package PostPoster
*/
// If uninstall not called from WordPress, then exit
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
/**
* Clean up plugin data on uninstall
*/
function post_poster_uninstall() {
global $wpdb;
// Remove plugin options
delete_option('pp_settings');
// Remove user meta (last settings)
$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key = 'pp_last_settings'");
// Clear all cached queries
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
'_transient_pp_query_%'
)
);
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
'_transient_timeout_pp_query_%'
)
);
// Remove any custom post meta added by the plugin (if any)
// This is for future extensibility
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE 'pp_%'");
// Clear any scheduled events (if any are added in the future)
wp_clear_scheduled_hook('pp_cleanup_cache');
// Flush rewrite rules one final time
flush_rewrite_rules();
}
// Execute cleanup
post_poster_uninstall();