clear-cache-everywhere
Last commit date
inc
8 months ago
clear-cache-everywhere.php
8 months ago
index.php
8 months ago
readme.txt
8 months ago
readme.txt
139 lines
| 1 | === Clear Cache Everywhere === |
| 2 | Contributors: apos37 |
| 3 | Tags: cache, clear cache, flush cache, performance, admin bar |
| 4 | Requires at least: 5.9 |
| 5 | Tested up to: 6.8 |
| 6 | Requires PHP: 7.4 |
| 7 | Stable tag: 1.1.1 |
| 8 | License: GPLv2 or later |
| 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 10 | |
| 11 | Clear all cache sources in one click from the WordPress admin bar, including WP cache, transients, sessions, browser cache. |
| 12 | |
| 13 | == Description == |
| 14 | |
| 15 | **Clear Cache Everywhere** allows administrators to instantly clear various cache sources directly from the WordPress admin bar. This ensures changes are reflected immediately without waiting for cache expiration. |
| 16 | |
| 17 | **Features:** |
| 18 | |
| 19 | - **One-Click Cache Clearing:** Clears WordPress object cache, page cache, all transients, and sessions with a single click. |
| 20 | - **Browser Cache Clearing:** Forces all visitors to reload fresh content by invalidating the browser cache. |
| 21 | - **Admin Bar Access:** Provides quick cache purging directly from the WordPress admin bar with an easy-to-use button (eraser icon). |
| 22 | - **Hosting Integration:** Optionally clears hosting-level cache if a purge URL is provided in the settings. |
| 23 | - **Third-Party Support:** Clears cache for various supported plugins, such as Elementor, Cornerstone, and other integrations. |
| 24 | - **Developer Hooks:** Developers can customize the cache clearing process using hooks to add more integrations or actions. |
| 25 | |
| 26 | By default, clearing the cache will execute the following actions: |
| 27 | |
| 28 | - **Flush Rewrite Rules:** Clears WordPress rewrite rules to immediately reflect changes to permalinks. |
| 29 | - **Clear WordPress Object Cache:** Clears the object cache in WordPress if enabled. |
| 30 | - **Clear All Transients:** Deletes all stored transients in the WordPress database. |
| 31 | - **Destroy PHP Sessions:** Clears PHP sessions if enabled. |
| 32 | - **Clear Cookies:** Clears all cookies except those related to logged-in users (`wordpress_logged_in_*`). |
| 33 | - **Force Browser Cache Invalidation:** Sends headers to force the browser to reload fresh content. |
| 34 | - **Clear Hosting-Level Cache:** Optionally calls a purge URL to clear hosting-level cache if a URL is provided. |
| 35 | |
| 36 | **Integrations:** |
| 37 | |
| 38 | The plugin already supports clearing cache for the following third-party plugins: |
| 39 | |
| 40 | - Cornerstone |
| 41 | - Elementor |
| 42 | - WP Super Cache |
| 43 | - W3 Total Cache |
| 44 | - WP Rocket |
| 45 | - LiteSpeed Cache |
| 46 | - SiteGround Optimizer |
| 47 | - Cloudflare |
| 48 | - Autoptimize |
| 49 | - Swift Performance |
| 50 | - Comet Cache |
| 51 | - WP Fastest Cache |
| 52 | - Hummingbird |
| 53 | - Nginx Helper |
| 54 | - WP-Optimize |
| 55 | |
| 56 | This plugin is ideal for developers, content managers, and site owners who need immediate cache flushing across multiple layers. |
| 57 | |
| 58 | == Installation == |
| 59 | |
| 60 | 1. Upload the plugin files to the `/wp-content/plugins/clear-cache-everywhere/` directory. |
| 61 | 2. Activate the plugin through the 'Plugins' menu in WordPress. |
| 62 | 3. The **Clear Cache** button will appear in the admin bar. |
| 63 | |
| 64 | == Frequently Asked Questions == |
| 65 | |
| 66 | = How does this plugin clear cache? = |
| 67 | It flushes WordPress object cache, transients, sessions, rewrite rules, and any configured third-party caches. If a hosting cache purge URL is set, it will be called as well. Additionally, it forces browsers to reload fresh content. |
| 68 | |
| 69 | = Does this work with all hosting providers? = |
| 70 | This depends on your hosting provider. If they offer a cache purge URL, you can configure it in the plugin settings. For example, if you have GoDaddy's Website Security and Backups, you can navigate to Firewall > Settings > Performance > Clear Cache, then grab the Clear Cache API link. |
| 71 | |
| 72 | = Will this force browsers to load fresh content? = |
| 73 | Yes! The plugin sends cache-control headers to prompt browsers to reload updated content. |
| 74 | |
| 75 | = Can I add custom cache clearing actions? = |
| 76 | Yes! Developers can hook into `cceverywhere_after_clear_cache` and `cceverywhere_custom_settings`: |
| 77 | |
| 78 | `<?php |
| 79 | // Action to purge a custom cache directory after clearing cache |
| 80 | add_action( 'cceverywhere_after_clear_cache', function() { |
| 81 | // Check if the custom cache purge option is enabled |
| 82 | $prefix = 'clear_cache_everywhere_'; |
| 83 | if ( get_option( $prefix . 'purge_custom_cache_directory', false ) ) { |
| 84 | // Purge a custom cache directory |
| 85 | $cache_dir = WP_CONTENT_DIR . '/cache/myplugin/'; |
| 86 | if ( file_exists( $cache_dir ) ) { |
| 87 | array_map( 'unlink', glob( $cache_dir . '*' ) ); |
| 88 | } |
| 89 | } |
| 90 | } ); |
| 91 | |
| 92 | // Filter to add custom settings field for the action above |
| 93 | add_filter( 'cceverywhere_custom_settings', function( $fields ) { |
| 94 | // Define a custom checkbox field |
| 95 | $fields[] = [ |
| 96 | 'key' => 'purge_custom_cache_directory', |
| 97 | 'title' => __( 'Purge Custom Cache Directory', 'clear-cache-everywhere' ), |
| 98 | 'type' => 'checkbox', |
| 99 | 'sanitize' => 'sanitize_checkbox', |
| 100 | 'section' => 'custom', |
| 101 | 'default' => FALSE, |
| 102 | 'comments' => __( 'Enable this option to automatically purge a custom cache directory (e.g., for your plugin\'s cache). The cache will be cleared after the global cache is cleared.', 'clear-cache-everywhere' ), |
| 103 | ]; |
| 104 | return $fields; |
| 105 | } ); |
| 106 | ?>` |
| 107 | |
| 108 | = Is there a function to trigger clearing cache everywhere? = |
| 109 | Yes! A helper function is available for you to use: `cceverywhere_clear_all( $log_results = false )`. |
| 110 | |
| 111 | The function returns the results of the cache clearing processing. Optionally, you can log the results by setting the `$log_results` parameter to `true`. This will log the results to the debug log. |
| 112 | |
| 113 | = Where can I request features and get further support? = |
| 114 | We recommend using our [website support forum](https://pluginrx.com/support/plugin/clear-cache-everywhere/) as the primary method for requesting features and getting help. You can also reach out via our [Discord support server](https://discord.gg/3HnzNEJVnR) or the [WordPress.org support forum](https://wordpress.org/support/plugin/clear-cache-everywhere/), but please note that WordPress.org doesn’t always notify us of new posts, so it’s not ideal for time-sensitive issues. |
| 115 | |
| 116 | == Demo == |
| 117 | https://youtu.be/61dk4iydfDA |
| 118 | |
| 119 | == Screenshots == |
| 120 | |
| 121 | 1. Settings page and admin bar button. |
| 122 | |
| 123 | == Changelog == |
| 124 | |
| 125 | = 1.1.1 = |
| 126 | * Tweak: Update admin bar spacing |
| 127 | |
| 128 | = 1.1.0 = |
| 129 | * Update: New support links |
| 130 | |
| 131 | = 1.0.2.1 = |
| 132 | * Fix: Sanitized cookie names |
| 133 | * Update: Moved scripts and styles to enqueue |
| 134 | |
| 135 | = 1.0.2 = |
| 136 | * Update: Updated author name and website per WordPress trademark policy |
| 137 | |
| 138 | = 1.0.1 = |
| 139 | * Initial Release on March 19, 2025 |