fix: address Phase 1 code review findings
- Serve cache via template_redirect so feeds/404/REST are excluded and query conditionals work - Bypass cache on query strings; key files by md5(host+path) to avoid collisions and support multisite - Write wp-content/wp-recache-cache.php drop-in server and set WP_CACHE in wp-config.php so advanced-cache.php actually runs - Only remove advanced-cache.php on deactivation when it is ours - Respect DONOTCACHEPAGE, non-200 responses; bots read but never warm cache - Fix comment purge (comment_post_ID) and heartbeat purge ($data arg) - Fix exclude URLs textarea parsing; purge all when exclusions change - Enqueue admin purge script on every admin-bar page, not just settings - Sync tests, add TESTING.md manual test guide
This commit is contained in:
@@ -19,11 +19,9 @@ class WP_Recache_Admin {
|
||||
add_action('wp_ajax_wp_recache_purge_all', [$this, 'ajax_purge_all']);
|
||||
add_action('wp_ajax_wp_recache_purge_url', [$this, 'ajax_purge_url']);
|
||||
add_action('admin_notices', [$this, 'admin_notices']);
|
||||
|
||||
wp_localize_script('jquery', 'wpRecache', [
|
||||
'ajaxUrl' => admin_url('admin-ajax.php'),
|
||||
'nonce' => wp_create_nonce('wp_recache_nonce'),
|
||||
]);
|
||||
add_action('admin_enqueue_scripts', 'wp_recache_enqueue_admin_bar_script');
|
||||
// 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');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,11 +91,13 @@ class WP_Recache_Admin {
|
||||
* @return array Sanitized URLs.
|
||||
*/
|
||||
public function sanitize_exclude_urls($input) {
|
||||
if (!is_array($input)) {
|
||||
return [];
|
||||
if (is_array($input)) {
|
||||
$input = implode("\n", $input);
|
||||
}
|
||||
|
||||
return array_map('sanitize_text_field', $input);
|
||||
$lines = array_filter(array_map('trim', explode("\n", (string) $input)));
|
||||
|
||||
return array_map('sanitize_text_field', $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,6 +110,10 @@ class WP_Recache_Admin {
|
||||
|
||||
$active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'cache';
|
||||
|
||||
if (!in_array($active_tab, ['cache', 'optimize', 'advanced'], true)) {
|
||||
$active_tab = 'cache';
|
||||
}
|
||||
|
||||
include WP_RECACHE_INC_PATH . 'Admin/views/settings.php';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user