Add wp_recache_rejected_cookies option (defaults: woocommerce_items_in_cart, wp_woocommerce_session_*, wp-postpass, comment_author_*, wordpress_*) that bypasses page cache when any listed cookie is present. Both the WP-level check (wp_recache_should_exclude) and the standalone drop-in apply the same exact/prefix matching logic. Editing the option regenerates the drop-in and purges all cache.
59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Plugin uninstall handler.
|
|
*
|
|
* @package WP_Recache
|
|
*/
|
|
|
|
defined('WP_UNINSTALL_PLUGIN') || exit;
|
|
|
|
// Delete all options.
|
|
$options = [
|
|
'wp_recache_cache_enabled',
|
|
'wp_recache_separate_mobile_cache',
|
|
'wp_recache_exclude_urls',
|
|
'wp_recache_rejected_cookies',
|
|
'wp_recache_minify_css',
|
|
'wp_recache_minify_js',
|
|
'wp_recache_lazyload_images',
|
|
'wp_recache_preload_enabled',
|
|
];
|
|
|
|
foreach ($options as $option) {
|
|
delete_option($option);
|
|
}
|
|
|
|
// Delete cache files.
|
|
$cache_path = WP_CONTENT_DIR . '/cache/wp-recache/';
|
|
if (is_dir($cache_path)) {
|
|
$files = new RecursiveIteratorIterator(
|
|
new RecursiveDirectoryIterator($cache_path, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
RecursiveIteratorIterator::CHILD_FIRST
|
|
);
|
|
|
|
foreach ($files as $file) {
|
|
if ($file->isDir()) {
|
|
rmdir($file->getRealPath());
|
|
} else {
|
|
unlink($file->getRealPath());
|
|
}
|
|
}
|
|
|
|
rmdir($cache_path);
|
|
}
|
|
|
|
// Remove advanced-cache.php if it's ours.
|
|
$advanced_cache = WP_CONTENT_DIR . '/advanced-cache.php';
|
|
if (file_exists($advanced_cache)) {
|
|
$content = file_get_contents($advanced_cache);
|
|
if (strpos($content, 'WP Recache') !== false) {
|
|
unlink($advanced_cache);
|
|
}
|
|
}
|
|
|
|
// Remove the standalone cache server.
|
|
$cache_server = WP_CONTENT_DIR . '/wp-recache-cache.php';
|
|
if (file_exists($cache_server)) {
|
|
unlink($cache_server);
|
|
}
|