|
1 <html> |
|
2 <head> |
|
3 <title>WP Super Cache Uninstall Script</title> |
|
4 </head> |
|
5 <body> |
|
6 <?php |
|
7 /** Include the bootstrap for setting up WordPress environment */ |
|
8 include( '../../../wp-load.php' ); |
|
9 |
|
10 if ( !is_user_logged_in() ) |
|
11 wp_die( 'You must be logged in to run this script.' ); |
|
12 |
|
13 if ( !current_user_can( 'install_plugins' ) ) |
|
14 wp_die( 'You do not have permission to run this script.' ); |
|
15 |
|
16 if ( defined( 'UNINSTALL_WPSUPERCACHE' ) ) |
|
17 wp_die( 'UNINSTALL_WPSUPERCACHE set somewhere else! It must only be set in uninstall.php' ); |
|
18 |
|
19 define( 'UNINSTALL_WPSUPERCACHE', '' ); |
|
20 |
|
21 if ( !defined( 'UNINSTALL_WPSUPERCACHE' ) || constant( 'UNINSTALL_WPSUPERCACHE' ) == '' ) |
|
22 wp_die( 'UNINSTALL_WPSUPERCACHE must be set to a non-blank value in uninstall.php' ); |
|
23 |
|
24 ?> |
|
25 <p>This script will uninstall the files and directories created by <a href='http://ocaoimh.ie/wp-super-cache/'>WP Super Cache</a>.</p> |
|
26 <?php |
|
27 if ( $_POST[ 'uninstall' ] ) { |
|
28 $plugins = (array)get_option( 'active_plugins' ); |
|
29 $key = array_search( 'wp-super-cache/wp-cache.php', $plugins ); |
|
30 if ( $key !== false ) { |
|
31 unset( $plugins[ $key ] ); |
|
32 update_option( 'active_plugins', $plugins ); |
|
33 echo "Disabled WP Super Cache plugin : <strong>DONE</strong><br />"; |
|
34 } |
|
35 |
|
36 if ( in_array( 'wp-super-cache/wp-cache.php', get_option( 'active_plugins' ) ) ) |
|
37 wp_die( 'WP Super Cache is still active. Please disable it on your plugins page first.' ); |
|
38 echo "Removing " . WP_CONTENT_DIR . "/cache/ :"; |
|
39 uninstall_supercache( WP_CONTENT_DIR . '/cache' ); |
|
40 echo " <strong>DONE</strong><br />"; |
|
41 echo "Removing " . WP_CONTENT_DIR . "/advanced-cache.php :"; |
|
42 @unlink( WP_CONTENT_DIR . "/advanced-cache.php" ); |
|
43 echo " <strong>DONE</strong><br />"; |
|
44 echo "Removing " . WP_CONTENT_DIR . "/wp-cache-config.php :"; |
|
45 @unlink( WP_CONTENT_DIR . "/wp-cache-config.php" ); |
|
46 echo " <strong>DONE</strong><br />"; |
|
47 echo "<p>Make sure you remove the following line from " . ABSPATH . "wp-config.php too.</p>"; |
|
48 echo "<blockquote><code>define('WP_CACHE', true);</code></blockquote>"; |
|
49 echo "<p><strong>Please comment out the UNINSTALL_WPSUPERCACHE <em>define()</em> in this file!</strong></p>"; |
|
50 wp_mail( $current_user->user_email, 'WP Super Cache Uninstalled', '' ); |
|
51 } else { |
|
52 ?> |
|
53 <form action='uninstall.php' method='POST'> |
|
54 <p>Click UNINSTALL to delete the following files and directories: |
|
55 <ol> |
|
56 <li> <?php echo WP_CONTENT_DIR . "/advanced-cache.php"; ?></li> |
|
57 <li> <?php echo WP_CONTENT_DIR . "/wp-cache-config.php"; ?></li> |
|
58 <li> <?php echo WP_CONTENT_DIR . '/cache'; ?></li> |
|
59 </ol> |
|
60 <input type='hidden' name='uninstall' value='1' /> |
|
61 <input type='submit' value='UNINSTALL' /> |
|
62 </form> |
|
63 <?php |
|
64 } |
|
65 |
|
66 function uninstall_supercache( $folderPath ) { // from http://www.php.net/manual/en/function.rmdir.php |
|
67 if ( trailingslashit( constant( 'ABSPATH' ) ) == trailingslashit( $folderPath ) ) |
|
68 return false; |
|
69 if ( @is_dir ( $folderPath ) ) { |
|
70 $dh = @opendir($folderPath); |
|
71 while( false !== ( $value = @readdir( $dh ) ) ) { |
|
72 if ( $value != "." && $value != ".." ) { |
|
73 $value = $folderPath . "/" . $value; |
|
74 if ( @is_dir ( $value ) ) { |
|
75 uninstall_supercache( $value ); |
|
76 } else { |
|
77 @unlink( $value ); |
|
78 } |
|
79 } |
|
80 } |
|
81 return @rmdir( $folderPath ); |
|
82 } else { |
|
83 return false; |
|
84 } |
|
85 } |
|
86 ?> |
|
87 </body> |
|
88 </html> |