# xspeed/1.0.2/uninstall.php

xSpeed Cache: AI-Powered Performance Hub with MCP, Caching &amp; CDN, version 1.0.2. 71 lines.

- Page: https://pluginprobe.com/plugins/xspeed/1.0.2/code/uninstall.php
- Raw: https://pluginprobe.com/plugins/xspeed/1.0.2/raw/uninstall.php
- Modified: 2026-06-01T17:33:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/xspeed/1.0.2/code/uninstall.php#L10-L20`.

```php
<?php
/**
 * Uninstall handler — deletes options, cache, and drop-in.
 *
 * @package XSpeed
 */

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}

xspeed_uninstall_cleanup();

/**
 * Run all uninstall cleanup. Wrapped in a function so locals don't pollute global scope.
 */
function xspeed_uninstall_cleanup() {
	delete_option( 'xspeed_options' );
	delete_option( 'xspeed_stats' );

	if ( ! function_exists( 'WP_Filesystem' ) ) {
		require_once ABSPATH . 'wp-admin/includes/file.php';
	}
	WP_Filesystem();
	global $wp_filesystem;
	if ( ! $wp_filesystem ) {
		return;
	}

	$cache_dir = WP_CONTENT_DIR . '/cache/xspeed';
	if ( $wp_filesystem->is_dir( $cache_dir ) ) {
		$wp_filesystem->delete( $cache_dir, true );
	}

	// Static-cache tree — separate from the flat-hash cache dir, holds
	// the {host}/{path}/index.html files the .htaccess rewrite block
	// serves directly. Same teardown rules as XSPEED_CACHE_DIR.
	$static_dir = WP_CONTENT_DIR . '/cache/xspeed-static';
	if ( $wp_filesystem->is_dir( $static_dir ) ) {
		$wp_filesystem->delete( $static_dir, true );
	}

	// Rewrite block in site-root .htaccess. WP's marker helpers handle
	// the "remove only our block" semantics — passing an empty array
	// strips the markers in place.
	$htaccess = ABSPATH . '.htaccess';
	if ( $wp_filesystem->exists( $htaccess ) && $wp_filesystem->is_writable( $htaccess ) ) {
		if ( ! function_exists( 'insert_with_markers' ) ) {
			require_once ABSPATH . 'wp-admin/includes/misc.php';
		}
		insert_with_markers( $htaccess, 'xSpeed Static Cache', array() );
	}

	$drop_in = WP_CONTENT_DIR . '/advanced-cache.php';
	if ( $wp_filesystem->exists( $drop_in ) ) {
		$contents = $wp_filesystem->get_contents( $drop_in );
		if ( is_string( $contents ) && false !== strpos( $contents, 'XSPEED_DROPIN' ) ) {
			$wp_filesystem->delete( $drop_in );
		}
	}

	$wp_config = ABSPATH . 'wp-config.php';
	if ( defined( 'WP_CACHE' ) && WP_CACHE && $wp_filesystem->is_writable( $wp_config ) ) {
		$config = $wp_filesystem->get_contents( $wp_config );
		if ( is_string( $config ) ) {
			$config = preg_replace( "/define\\(\\s*['\"]WP_CACHE['\"]\\s*,\\s*true\\s*\\);\\s*\\n?/", '', $config );
			$wp_filesystem->put_contents( $wp_config, $config, FS_CHMOD_FILE );
		}
	}
}

```
