- 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
134 lines
6.1 KiB
PHP
134 lines
6.1 KiB
PHP
<?php
|
|
/**
|
|
* Settings page template.
|
|
*
|
|
* @package WP_Recache
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$stats = WP_Recache_Admin::get_cache_stats();
|
|
?>
|
|
|
|
<div class="wrap">
|
|
<h1>WP Recache Settings</h1>
|
|
|
|
<form method="post" action="options.php">
|
|
<?php settings_fields('wp_recache_settings'); ?>
|
|
|
|
<nav class="nav-tab-wrapper">
|
|
<a href="?page=wp-recache&tab=cache" class="nav-tab <?php echo $active_tab === 'cache' ? 'nav-tab-active' : ''; ?>">Cache</a>
|
|
<a href="?page=wp-recache&tab=optimize" class="nav-tab <?php echo $active_tab === 'optimize' ? 'nav-tab-active' : ''; ?>">Optimization</a>
|
|
<a href="?page=wp-recache&tab=advanced" class="nav-tab <?php echo $active_tab === 'advanced' ? 'nav-tab-active' : ''; ?>">Advanced</a>
|
|
</nav>
|
|
|
|
<div class="tab-content" style="margin-top: 20px;">
|
|
<?php if ($active_tab === 'cache') : ?>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">Enable Cache</th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="wp_recache_cache_enabled" value="1" <?php checked(get_option('wp_recache_cache_enabled', true)); ?>>
|
|
Enable page caching
|
|
</label>
|
|
<p class="description">Serve cached HTML pages to anonymous visitors.</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row">Separate Mobile Cache</th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="wp_recache_separate_mobile_cache" value="1" <?php checked(get_option('wp_recache_separate_mobile_cache', false)); ?>>
|
|
Create separate cache for mobile devices
|
|
</label>
|
|
<p class="description">Useful for sites with different layouts for mobile.</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row">Exclude URLs</th>
|
|
<td>
|
|
<textarea name="wp_recache_exclude_urls" rows="5" cols="50" class="large-text"><?php echo esc_textarea(implode("\n", get_option('wp_recache_exclude_urls', ['/cart', '/checkout', '/my-account']))); ?></textarea>
|
|
<p class="description">One URL per line. These pages will not be cached.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<h2>Cache Statistics</h2>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">Cached Files</th>
|
|
<td><?php echo esc_html($stats['files']); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row">Cache Size</th>
|
|
<td><?php echo esc_html($stats['size_formatted']); ?></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php elseif ($active_tab === 'optimize') : ?>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">Minify CSS</th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="wp_recache_minify_css" value="1" <?php checked(get_option('wp_recache_minify_css', false)); ?>>
|
|
Minify CSS files
|
|
</label>
|
|
<p class="description">Remove whitespace and comments from CSS files.</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row">Minify JavaScript</th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="wp_recache_minify_js" value="1" <?php checked(get_option('wp_recache_minify_js', false)); ?>>
|
|
Minify JavaScript files
|
|
</label>
|
|
<p class="description">Remove whitespace and comments from JS files.</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row">Lazy Load Images</th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="wp_recache_lazyload_images" value="1" <?php checked(get_option('wp_recache_lazyload_images', false)); ?>>
|
|
Enable lazy loading for images
|
|
</label>
|
|
<p class="description">Load images only when they enter the viewport.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php elseif ($active_tab === 'advanced') : ?>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">Preload Cache</th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="wp_recache_preload_enabled" value="1" <?php checked(get_option('wp_recache_preload_enabled', false)); ?>>
|
|
Enable cache preloading
|
|
</label>
|
|
<p class="description">Automatically crawl sitemap to warm cache.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<h2>Tools</h2>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">Purge Cache</th>
|
|
<td>
|
|
<button type="button" class="button" onclick="wpRecachePurgeAll();">Purge All Cache</button>
|
|
<p class="description">Delete all cached files.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php submit_button('Save Settings'); ?>
|
|
</form>
|
|
</div>
|