forked from bangbay/wp-user-avatar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
52 lines (50 loc) · 1.79 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
<?php
/**
* @package WP User Avatar
* @version 1.5.2
*/
// Remove user metadata and options on plugin delete
if(!defined('WP_UNINSTALL_PLUGIN')){
die(__('You are not allowed to call this page directly.'));
}
global $wpdb, $blog_id, $switched;
$users = get_users();
// Remove settings for all sites in multisite
if(is_multisite()){
$blogs = $wpdb->get_results("SELECT * FROM $wpdb->blogs");
foreach($users as $user){
foreach($blogs as $blog){
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog->blog_id).'user_avatar');
}
}
foreach($blogs as $blog){
switch_to_blog($blog->blog_id);
delete_option('avatar_default_wp_user_avatar');
delete_option('wp_user_avatar_tinymce');
delete_option('wp_user_avatar_allow_upload');
delete_option('wp_user_avatar_disable_gravatar');
delete_option('wp_user_avatar_load_scripts');
delete_option('wp_user_avatar_upload_size_limit');
delete_option('wp_user_avatar_default_avatar_updated');
delete_option('wp_user_avatar_users_updated');
delete_option('wp_user_avatar_media_updated');
}
} else {
foreach($users as $user){
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar');
}
delete_option('avatar_default_wp_user_avatar');
delete_option('wp_user_avatar_tinymce');
delete_option('wp_user_avatar_allow_upload');
delete_option('wp_user_avatar_disable_gravatar');
delete_option('wp_user_avatar_load_scripts');
delete_option('wp_user_avatar_upload_size_limit');
delete_option('wp_user_avatar_default_avatar_updated');
delete_option('wp_user_avatar_users_updated');
delete_option('wp_user_avatar_media_updated');
}
// Delete post meta
delete_post_meta_by_key('_wp_attachment_wp_user_avatar');
// Reset all default avatars to Mystery Man
update_option('avatar_default', 'mystery');
?>