diff --git a/includes/Activator.php b/includes/Activator.php index 856ead6..676d0c9 100644 --- a/includes/Activator.php +++ b/includes/Activator.php @@ -15,7 +15,7 @@ class WP_Recache_Activator { public static function activate() { self::create_cache_directory(); self::set_default_options(); - self::create_cache_server(); + self::write_cookie_bypass_script(); self::create_advanced_cache(); self::set_wp_cache_constant(true); self::flush_rewrite_rules(); @@ -48,13 +48,7 @@ class WP_Recache_Activator { 'cache_enabled' => true, 'separate_mobile_cache' => false, 'exclude_urls' => ['/cart', '/checkout', '/my-account'], - 'rejected_cookies' => [ - 'woocommerce_items_in_cart', - 'wp_woocommerce_session_*', - 'wp-postpass', - 'comment_author_*', - 'wordpress_*', - ], + 'rejected_cookies' => WP_RECACHE_DEFAULT_REJECTED_COOKIES, 'minify_css' => false, 'minify_js' => false, 'lazyload_images' => false, @@ -69,19 +63,13 @@ class WP_Recache_Activator { } /** - * Write the standalone cache server required by the advanced-cache.php - * drop-in. Must run without WordPress loaded. + * Write the standalone cache bypass script required by advanced-cache.php. + * Must run without WordPress loaded. * * Public so Admin can regenerate the drop-in when options change. */ - public static function create_cache_server() { - $rejected_cookies = get_option('wp_recache_rejected_cookies', [ - 'woocommerce_items_in_cart', - 'wp_woocommerce_session_*', - 'wp-postpass', - 'comment_author_*', - 'wordpress_*', - ]); + public static function write_cookie_bypass_script() { + $rejected_cookies = get_option('wp_recache_rejected_cookies', WP_RECACHE_DEFAULT_REJECTED_COOKIES); $cookies_php = var_export($rejected_cookies, true); diff --git a/includes/Admin/Admin.php b/includes/Admin/Admin.php index f06a94f..742877b 100644 --- a/includes/Admin/Admin.php +++ b/includes/Admin/Admin.php @@ -23,7 +23,7 @@ class WP_Recache_Admin { // New exclusions must not leave stale files that the drop-in would still serve. add_action('update_option_wp_recache_exclude_urls', 'wp_recache_delete_all_cache'); add_action('update_option_wp_recache_rejected_cookies', function () { - WP_Recache_Activator::create_cache_server(); + WP_Recache_Activator::write_cookie_bypass_script(); wp_recache_delete_all_cache(); }); } @@ -66,13 +66,7 @@ class WP_Recache_Admin { register_setting('wp_recache_settings', 'wp_recache_rejected_cookies', [ 'type' => 'array', 'sanitize_callback' => [$this, 'sanitize_rejected_cookies'], - 'default' => [ - 'woocommerce_items_in_cart', - 'wp_woocommerce_session_*', - 'wp-postpass', - 'comment_author_*', - 'wordpress_*', - ], + 'default' => WP_RECACHE_DEFAULT_REJECTED_COOKIES, ]); register_setting('wp_recache_settings', 'wp_recache_minify_css', [ diff --git a/includes/Admin/views/settings.php b/includes/Admin/views/settings.php index 21f45c5..8c923a1 100644 --- a/includes/Admin/views/settings.php +++ b/includes/Admin/views/settings.php @@ -55,13 +55,7 @@ $stats = WP_Recache_Admin::get_cache_stats();
One cookie name per line. Visitors with these cookies bypass the cache. Use * as a suffix to match a prefix (e.g. comment_author_*).