-
Notifications
You must be signed in to change notification settings - Fork 11
/
uninstall.php
49 lines (38 loc) · 879 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
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Uninstall Surge
*
* @package Surge
*/
namespace Surge;
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
include_once( __DIR__ . '/include/common.php' );
// Remove advanced-cache.php only if its ours.
if ( file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) {
$contents = file_get_contents( WP_CONTENT_DIR . '/advanced-cache.php' );
if ( strpos( $contents, 'namespace Surge;' ) !== false ) {
unlink( WP_CONTENT_DIR . '/advanced-cache.php' );
}
}
// Delete the cache directory
function delete( $path ) {
if ( is_file( $path ) ) {
unlink( $path );
return;
}
if ( ! is_dir( $path ) ) {
return;
}
$entries = scandir( $path );
foreach ( $entries as $entry ) {
if ( $entry == '.' || $entry == '..' ) {
continue;
}
delete( $path . '/' . $entry );
}
rmdir( $path );
}
delete( CACHE_DIR );
delete_option( 'surge_installed' );