PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 3.6
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v3.6
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
powered-cache / uninstall.php

uninstall.php in Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score 3.6, at uninstall.php

87 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall Powered Cache
4 * Deletes all plugin related data and configurations
5 *
6 * @package PoweredCache
7 */
8
9 // phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
10 // phpcs:disable WordPress.WhiteSpace.PrecisionAlignment.Found
11
12 // Exit if accessed directly.
13 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
14 exit;
15 }
16
17 require_once 'powered-cache.php';
18
19 // flush cache
20 \PoweredCache\Utils\powered_cache_flush();
21
22 if ( is_multisite() ) {
23 $sites = get_sites();
24 foreach ( $sites as $site ) {
25 switch_to_blog( $site->blog_id );
26 \PoweredCache\Utils\log( sprintf( 'Uninstalling site %s', $site->blog_id ) );
27 powered_cache_uninstall_site();
28 restore_current_blog();
29 }
30 } else {
31 \PoweredCache\Utils\log( sprintf( 'Uninstalling...' ) );
32 powered_cache_uninstall_site();
33 }
34
35 \PoweredCache\Config::factory()->define_wp_cache( false );
36
37 $object_cache_file = untrailingslashit( WP_CONTENT_DIR ) . '/object-cache.php';
38
39 // delete object cache file
40 if ( file_exists( $object_cache_file ) && false !== strpos( file_get_contents( $object_cache_file ), 'POWERED_OBJECT_CACHE' ) ) {
41 \PoweredCache\Utils\log( sprintf( 'Removing: %s', 'object-cache.php' ) );
42
43 unlink( untrailingslashit( WP_CONTENT_DIR ) . '/object-cache.php' );
44 }
45
46 // delete advanced cache file
47 if ( file_exists( untrailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php' ) ) {
48 \PoweredCache\Utils\log( sprintf( 'Removing: %s', 'advanced-cache.php' ) );
49
50 unlink( untrailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php' );
51 }
52
53 // delete cache directory
54 if ( file_exists( \PoweredCache\Utils\get_cache_dir() ) ) {
55 \PoweredCache\Utils\log( sprintf( 'Removing dir: %s', \PoweredCache\Utils\get_cache_dir() ) );
56 \PoweredCache\Utils\remove_dir( \PoweredCache\Utils\get_cache_dir() );
57 }
58
59 // delete configuration files
60 if ( file_exists( WP_CONTENT_DIR . '/pc-config' ) ) {
61 \PoweredCache\Utils\log( 'Removing config dir...' );
62 \PoweredCache\Utils\remove_dir( WP_CONTENT_DIR . '/pc-config' );
63 }
64
65 /**
66 * Uninstall Powered Cache
67 *
68 * @since 2.0
69 */
70 function powered_cache_uninstall_site() {
71 // delete network settings
72 delete_site_option( \PoweredCache\Constants\SETTING_OPTION );
73 delete_site_option( \PoweredCache\Constants\DB_VERSION_OPTION_NAME );
74
75 // delete site settings
76 delete_option( \PoweredCache\Constants\SETTING_OPTION );
77 delete_option( \PoweredCache\Constants\DB_VERSION_OPTION_NAME );
78
79 // remove cron tasks
80 wp_clear_scheduled_hook( \PoweredCache\Constants\PURGE_CACHE_CRON_NAME );
81 wp_clear_scheduled_hook( \PoweredCache\Constants\PURGE_FO_CRON_NAME );
82 wp_clear_scheduled_hook( \PoweredCache\Constants\DEFERRED_PRELOAD_QUEUE_CRON_NAME );
83
84 delete_site_transient( \PoweredCache\Constants\PURGE_CACHE_PLUGIN_NOTICE_TRANSIENT );
85 delete_transient( \PoweredCache\Constants\PURGE_CACHE_PLUGIN_NOTICE_TRANSIENT );
86 }
87