-
Notifications
You must be signed in to change notification settings - Fork 5
/
uninstall.php
executable file
·55 lines (45 loc) · 1.21 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
<?php
/**
* Fired when the plugin is uninstalled.
*
* @link http://www.alexisvillegas.com
* @since 1.0.0
*
* @package Image_Gallery_Metabox
*/
// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// If user doesn't have the right permissions, then exit.
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
// If action didn't originate on the proper page, then exit.
if ( __FILE__ !== WP_UNINSTALL_PLUGIN ) {
return;
}
// Delete plugin options from database.
if ( is_multisite() ) {
if ( function_exists( 'get_sites' ) && class_exists( 'WP_Site_Query' ) ) {
$sites = get_sites();
if ( $sites ) {
foreach ( $sites as $site ) {
switch_to_blog( $site->blog_id );
// Delete post meta data.
$site_posts = get_posts( array( 'posts_per_page' => -1 ) );
foreach ( $site_posts as $site_post ) {
delete_post_meta( $site_post->ID, '_igmb_image_gallery_id' );
}
restore_current_blog();
}
}
return;
}
} else {
// Delete post meta data.
$site_posts = get_posts( array( 'posts_per_page' => -1 ) );
foreach ( $site_posts as $site_post ) {
delete_post_meta( $site_post->ID, '_igmb_image_gallery_id' );
}
}