PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.0.4
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.0.4
1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2.0 All 28 releases
xspeed / uninstall.php

uninstall.php in xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN 1.0.4, at uninstall.php

71 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall handler — deletes options, cache, and drop-in.
4 *
5 * @package XSpeed
6 */
7
8 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
9 exit;
10 }
11
12 xspeed_uninstall_cleanup();
13
14 /**
15 * Run all uninstall cleanup. Wrapped in a function so locals don't pollute global scope.
16 */
17 function xspeed_uninstall_cleanup() {
18 delete_option( 'xspeed_options' );
19 delete_option( 'xspeed_stats' );
20
21 if ( ! function_exists( 'WP_Filesystem' ) ) {
22 require_once ABSPATH . 'wp-admin/includes/file.php';
23 }
24 WP_Filesystem();
25 global $wp_filesystem;
26 if ( ! $wp_filesystem ) {
27 return;
28 }
29
30 $cache_dir = WP_CONTENT_DIR . '/cache/xspeed';
31 if ( $wp_filesystem->is_dir( $cache_dir ) ) {
32 $wp_filesystem->delete( $cache_dir, true );
33 }
34
35 // Static-cache tree — separate from the flat-hash cache dir, holds
36 // the {host}/{path}/index.html files the .htaccess rewrite block
37 // serves directly. Same teardown rules as XSPEED_CACHE_DIR.
38 $static_dir = WP_CONTENT_DIR . '/cache/xspeed-static';
39 if ( $wp_filesystem->is_dir( $static_dir ) ) {
40 $wp_filesystem->delete( $static_dir, true );
41 }
42
43 // Rewrite block in site-root .htaccess. WP's marker helpers handle
44 // the "remove only our block" semantics — passing an empty array
45 // strips the markers in place.
46 $htaccess = ABSPATH . '.htaccess';
47 if ( $wp_filesystem->exists( $htaccess ) && $wp_filesystem->is_writable( $htaccess ) ) {
48 if ( ! function_exists( 'insert_with_markers' ) ) {
49 require_once ABSPATH . 'wp-admin/includes/misc.php';
50 }
51 insert_with_markers( $htaccess, 'xSpeed Static Cache', array() );
52 }
53
54 $drop_in = WP_CONTENT_DIR . '/advanced-cache.php';
55 if ( $wp_filesystem->exists( $drop_in ) ) {
56 $contents = $wp_filesystem->get_contents( $drop_in );
57 if ( is_string( $contents ) && false !== strpos( $contents, 'XSPEED_DROPIN' ) ) {
58 $wp_filesystem->delete( $drop_in );
59 }
60 }
61
62 $wp_config = ABSPATH . 'wp-config.php';
63 if ( defined( 'WP_CACHE' ) && WP_CACHE && $wp_filesystem->is_writable( $wp_config ) ) {
64 $config = $wp_filesystem->get_contents( $wp_config );
65 if ( is_string( $config ) ) {
66 $config = preg_replace( "/define\\(\\s*['\"]WP_CACHE['\"]\\s*,\\s*true\\s*\\);\\s*\\n?/", '', $config );
67 $wp_filesystem->put_contents( $wp_config, $config, FS_CHMOD_FILE );
68 }
69 }
70 }
71