-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuninstall.php
39 lines (33 loc) · 920 Bytes
/
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
<?php
/**
* Delete the plugin artefacts.
*
* @since 1.0.01
*/
// if uninstall.php is not called by WordPress, die
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
die;
}
function pretix_widget_delete_files_recursive($dir) {
$files = glob($dir . '/*');
foreach ($files as $file) {
if (is_dir($file)) {
pretix_widget_delete_files_recursive($file);
rmdir($file);
} else {
unlink($file);
}
}
}
// Remove transients
delete_transient('pretix_widget_custom_css');
// Remove files in the uploads directory
$uploads_dir = wp_upload_dir();
$plugin_dir = trailingslashit($uploads_dir['basedir']) . 'pretix-widget';
if (is_dir($plugin_dir)) {
error_log('Removing directory ' . $plugin_dir);
// Remove all files in the directory
pretix_widget_delete_files_recursive($plugin_dir);
// Remove the directory itself
rmdir($plugin_dir);
}