A simple WordPress plugin that automatically purges the entire Cloudflare cache when content is published or updated. Works as an addon to the official Cloudflare WordPress plugin.
This plugin extends the functionality of the official Cloudflare plugin by automatically purging the entire Cloudflare cache (not just specific URLs) whenever:
- A post or page is published (new or scheduled)
- A post or page is updated
- Any content transitions to the "publish" status
- The full WP Rocket cache is cleared
- ✅ Automatically purges entire Cloudflare cache on content publish/update
- ✅ Works with scheduled posts
- ✅ Triggers full Cloudflare purge when WP Rocket full cache is cleared
- ✅ Compatible with the official Cloudflare plugin
- ✅ Uses Cloudflare plugin's API directly (no fallbacks)
- ✅ Forces Cloudflare
plugin_specific_cacheoption toonat runtime - ✅ Debug logging support
- ✅ Follows WordPress coding standards
- ✅ Simple namespace-based architecture
- WordPress 5.0 or higher
- PHP 7.4 or higher
- Cloudflare WordPress plugin installed and configured
-
Download or clone this repository into your WordPress plugins directory:
cd wp-content/plugins git clone https://github.com/beapi/cloudflare-extra-purge-addon.git -
Make sure the official Cloudflare plugin is installed and configured with your API credentials.
-
Activate the plugin through the 'Plugins' menu in WordPress.
The plugin hooks into WordPress post lifecycle events:
transition_post_status- Detects when posts transition to "publish" statussave_post- Detects when published posts are updatedpublish_future_post- Handles scheduled post publicationsafter_rocket_clean_domain- Triggers a Cloudflare full purge when WP Rocket clears domain cachepre_option_plugin_specific_cache- Forcesplugin_specific_cachetoonwhen read by WordPress
When any of these events occur, the plugin:
- Checks if the Cloudflare plugin is active and its API is available
- Uses the Cloudflare plugin's
Hooksclass to callpurgeCacheEverything() - Purges the entire cache using
purge_everything: true
Note: If the Cloudflare plugin is not active or its API is not available, this plugin does nothing (no fallbacks).
No configuration needed! The plugin automatically uses the Cloudflare plugin's API. Make sure the official Cloudflare plugin is installed, activated, and properly configured.
Some Cloudflare plugin internals only allow full cache purge when plugin_specific_cache is set to on.
This addon forces the value at runtime using the pre_option_plugin_specific_cache filter.
That means:
- The value can remain
offin the database - The Cloudflare plugin still receives
onduring execution - No manual database update is required
To enable debug logging, add this to your wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );Purge operations will be logged to /wp-content/debug.log with the prefix [Cloudflare Extra Purge].
This plugin follows:
- WordPress Coding Standards (WPCS)
- WordPress VIP coding requirements
- PSR-12 for PHP formatting
- Uses PHP namespaces for code organization
Test the plugin by:
- Publishing a new post
- Updating an existing published post
- Scheduling a post for future publication
- Clicking "Clear and preload cache" (or full cache clear) in WP Rocket
- Checking Cloudflare dashboard or debug logs to verify cache purge
GPL v2 or later
For issues, feature requests, or contributions, please open an issue on GitHub.
- Added runtime override for Cloudflare
plugin_specific_cacheoption (on) - Added WP Rocket integration: full Cloudflare purge on
after_rocket_clean_domain
- Initial release
- Automatic cache purge on post publish/update
- Support for scheduled posts
- Integration with official Cloudflare plugin
- Namespace-based architecture
- No fallbacks - uses Cloudflare plugin API exclusively