-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
executable file
·52 lines (46 loc) · 1.31 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
// if uninstall.php is not called by WordPress, die
if (!defined('WP_UNINSTALL_PLUGIN')) {
die;
}
global $wpdb, $wp_filesystem;
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}optimum_gravatar_cache");
$options = get_option('OGC_options');
if ($options !== false) {
delete_option('OGC_resolved');
delete_option('OGC_options');
delete_option('OGC_avatarUsedSizes');
if ($options['cache_directory']) {
if (is_dir(ABSPATH.$options['cache_directory']) && validateCacheDirectory($options['cache_directory'])) {
$wp_filesystem->rmdir(ABSPATH.$options['cache_directory'], true);
}
}
}
function validateCacheDirectory($path)
{
$systemDirectoriesConstants=array(
ABSPATH,
WP_CONTENT_DIR,
);
$systemDirectories=array(
ABSPATH."wp-admin",
ABSPATH."wp-includes",
WPINC,
WP_LANG_DIR,
WP_TEMP_DIR,
WPMU_PLUGIN_DIR,
WP_ADMIN_DIR,
WP_PLUGIN_DIR,
);
foreach ($systemDirectoriesConstants as $systemDirectory) {
if (ABSPATH.$path == $systemDirectory) {
return false;
}
}
foreach ($systemDirectories as $systemDirectory) {
if (ABSPATH.$path == $systemDirectory || strpos(ABSPATH.$path, $systemDirectory) === 0) {
return false;
}
}
return true;
}