-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathuninstall.php
More file actions
46 lines (37 loc) · 1.16 KB
/
Copy pathuninstall.php
File metadata and controls
46 lines (37 loc) · 1.16 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
<?php
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit();
}
// Drop the hypeanimations table from the database
global $wpdb;
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}hypeanimations");
// Delete the hypeanimations_db_version option
delete_option('hypeanimations_db_version');
/**
* Delete a directory and its contents recursively
*
* @param string $dir The directory path to delete
*/
function hypeanimations_remove_dir($dir) {
if (!is_dir($dir)) {
return;
}
// Get all files including hidden ones
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($path)) {
hypeanimations_remove_dir($path);
} else {
unlink($path);
}
}
return rmdir($dir);
}
// Get the WordPress upload directory and set the hypeanimations directory path
$upload_dir = wp_upload_dir();
$anims_dir = $upload_dir['basedir'] . '/hypeanimations/';
// Check if the hypeanimations directory exists and remove it along with its contents
if (file_exists($anims_dir)) {
hypeanimations_remove_dir($anims_dir);
}