-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
49 lines (38 loc) · 1.06 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
<?php
/**
* IMPORTANT: Keep code in this file compatible with PHP 5.2
*/
defined('WPINC') || exit(1);
defined('WP_UNINSTALL_PLUGIN') || exit(1);
require __DIR__.'/constants.php';
if (version_compare(PHP_VERSION, SFI_MIN_PHP, '<') ||
version_compare(get_bloginfo('version'), SFI_MIN_WP, '<')
) {
return;
}
if (!current_user_can('install_plugins')) {
wp_die(esc_html__(
'You are not allowed to perform this action!',
'smart-featured-image'
));
}
require __DIR__.'/vendor/autoload.php';
$post_types = SmartFeaturedImage()->utilities->featuredImage->postTypes();
if (is_multisite()) {
$blogs = get_sites(array('number' => -1));
foreach ($blogs as $blog) {
switch_to_blog($blog->blog_id);
deleteSmartFeaturedImageOptions($post_types);
}
restore_current_blog();
} else {
deleteSmartFeaturedImageOptions($post_types);
}
function deleteSmartFeaturedImageOptions($post_types)
{
foreach ($post_types as $post_type) {
SmartFeaturedImage()->utilities->options
->defaultFeaturedImage($post_type->name)
->delete();
}
}