PurgeBar – Cache Purge for Cloudflare
Purge Cloudflare cache from the WordPress Admin Bar, with automatic purging on content changes.
by abolfazlmk2h · github.com/abolfazlmk2h/purgebar · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/abolfazlmk2h/purgebar/releases/download/v1.0.0/purgebar.zipA lightweight WordPress plugin that purges Cloudflare cache from the Admin Bar, and purges the affected URLs automatically when content changes.
- Admin Bar: "Purge this page" and "Purge everything"
- Automatic purge on publish, update, unpublish, trash or delete, and on comment approval. It covers the post, home page, feed, archives and author page, and runs non-blocking at shutdown.
- Fast Setup: a pre-filled Cloudflare token link, plus automatic Zone ID detection
- Secure: the token is never rendered back into the page,
wp-config.phpconstants are supported, and every request is checked for a nonce and capability
Requires WordPress 6.5+ and PHP 7.4+. Tested up to WordPress 7.1.
Installation
Download the latest release zip and upload it via Plugins → Add New → Upload Plugin. Or clone it into wp-content/plugins/:
git clone https://github.com/abolfazlmk2h/purgebar.git wp-content/plugins/purgebar
Then go to Settings → PurgeBar and click Create token on Cloudflare → paste the token → Fast Setup.
Configuration via wp-config.php
define( 'PURGEBAR_API_TOKEN', 'your-api-token' );
define( 'PURGEBAR_ZONE_ID', 'your-zone-id' );
Token permissions: Cache Purge is required. Zone Read is needed only for Fast Setup's zone detection.
Hooks
| Hook | Type | Arguments | Purpose |
|---|---|---|---|
purgebar_capability |
filter | string $cap |
Capability required to purge (default manage_options) |
purgebar_post_purge_urls |
filter | string[] $urls, WP_Post $post |
URLs purged when a post changes |
purgebar_after_auto_purge |
action | string[] $urls, true\|WP_Error $result |
Runs after an automatic purge |
Example: also purge a custom landing page whenever a product changes:
add_filter( 'purgebar_post_purge_urls', function ( $urls, $post ) {
if ( $post->post_type === 'product' ) {
$urls[] = home_url( '/shop/' );
}
return $urls;
}, 10, 2 );
Building a release zip
.gitattributes excludes development files from git archive:
git archive --format=zip --prefix=purgebar/ -o purgebar.zip HEAD
Contributing
Issues and pull requests are welcome. Please keep changes compatible with the minimum WordPress and PHP versions above.
License
GPL-2.0-or-later. This project is not affiliated with or endorsed by Cloudflare, Inc.
Releases
1 release. Each count is every asset in that release; expand a row for the breakdown.