| 1 |
<?php |
| 2 |
/** |
| 3 |
* Uninstall Powered Cache |
| 4 |
* Deletes all plugin related data and configurations |
| 5 |
*/ |
| 6 |
|
| 7 |
// Exit if accessed directly. |
| 8 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
include_once( 'powered-cache.php' ); |
| 13 |
|
| 14 |
global $powered_cache_fs; |
| 15 |
|
| 16 |
// clean cache |
| 17 |
powered_cache_flush(); |
| 18 |
|
| 19 |
// delete settings |
| 20 |
delete_option( 'powered_cache_settings' ); |
| 21 |
// delete preloader runtime option, just in case |
| 22 |
delete_option( 'powered_cache_preload_runtime_option' ); |
| 23 |
|
| 24 |
// turn off page cache |
| 25 |
Powered_Cache_Config::factory()->define_wp_cache( false ); |
| 26 |
|
| 27 |
// delete object cache file |
| 28 |
if ( file_exists( untrailingslashit( WP_CONTENT_DIR ) . '/object-cache.php' ) ) { |
| 29 |
$powered_cache_fs->delete( untrailingslashit( WP_CONTENT_DIR ) . '/object-cache.php' ); |
| 30 |
} |
| 31 |
|
| 32 |
// delete advanced cache file |
| 33 |
if ( file_exists( untrailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php' ) ) { |
| 34 |
$powered_cache_fs->delete( untrailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php' ); |
| 35 |
} |
| 36 |
|
| 37 |
// delete cache directory |
| 38 |
if ( file_exists( powered_cache_get_cache_dir() ) ) { |
| 39 |
$powered_cache_fs->delete( powered_cache_get_cache_dir(), true ); |
| 40 |
} |
| 41 |
|
| 42 |
// delete configuration files |
| 43 |
if ( file_exists( WP_CONTENT_DIR . '/pc-config' ) ) { |
| 44 |
$powered_cache_fs->delete( WP_CONTENT_DIR . '/pc-config', true ); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
// remove cron tasks |
| 49 |
wp_clear_scheduled_hook( 'powered_cache_preload_hook' ); |
| 50 |
wp_clear_scheduled_hook( 'powered_cache_preload_child_process' ); |
| 51 |
wp_clear_scheduled_hook( 'powered_cache_purge_cache' ); |
| 52 |
|
| 53 |
|