forked from wp-media/wp-rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
executable file
·57 lines (45 loc) · 1.55 KB
/
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
50
51
52
53
54
55
56
57
<?php
defined( 'WP_UNINSTALL_PLUGIN' ) || die( 'Cheatin’ uh?' );
if ( ! defined( 'WP_ROCKET_CACHE_ROOT_PATH' ) ) {
define( 'WP_ROCKET_CACHE_ROOT_PATH', WP_CONTENT_DIR . '/cache/' );
}
// Delete all transients.
delete_site_transient( 'update_wprocket' );
delete_site_transient( 'update_wprocket_response' );
delete_transient( 'wp_rocket_settings' );
delete_transient( 'rocket_cloudflare_ips' );
delete_transient( 'rocket_send_analytics_data' );
// Delete WP Rocket options.
delete_option( 'wp_rocket_settings' );
delete_option( 'rocket_analytics_notice_displayed' );
// Delete Compatibility options.
delete_option( 'rocket_jetpack_eu_cookie_widget' );
// Delete all user meta related to WP Rocket.
delete_metadata( 'user', '', 'rocket_boxes', '', true );
// Clear scheduled WP Rocket Cron.
wp_clear_scheduled_hook( 'rocket_purge_time_event' );
wp_clear_scheduled_hook( 'rocket_database_optimization_time_event' );
/**
* Remove all cache files.
*
* @since 1.2.0
*
* @param string $dir Path to directory.
*/
function rocket_uninstall_rrmdir( $dir ) {
if ( ! is_dir( $dir ) ) {
@unlink( $dir );
return;
}
$globs = glob( $dir . '/*', GLOB_NOSORT );
if ( $globs ) {
foreach ( $globs as $file ) {
is_dir( $file ) ? rocket_uninstall_rrmdir( $file ) : @unlink( $file );
}
}
@rmdir( $dir );
}
rocket_uninstall_rrmdir( WP_ROCKET_CACHE_ROOT_PATH . 'wp-rocket/' );
rocket_uninstall_rrmdir( WP_ROCKET_CACHE_ROOT_PATH . 'min/' );
rocket_uninstall_rrmdir( WP_ROCKET_CACHE_ROOT_PATH . 'busting/' );
rocket_uninstall_rrmdir( WP_CONTENT_DIR . '/wp-rocket-config/' );