Skip to content

Instantly share code, notes, and snippets.

@stoffl6781
Created July 29, 2025 11:53
Show Gist options
  • Save stoffl6781/668ce10418b68ae378c48a6e028d34e3 to your computer and use it in GitHub Desktop.
Save stoffl6781/668ce10418b68ae378c48a6e028d34e3 to your computer and use it in GitHub Desktop.
function clp_clear_varnish_cache() {
if (class_exists('ClpVarnishCacheManager')) {
$manager = new ClpVarnishCacheManager();
$host = $_SERVER['HTTP_HOST'] ?? '';
if (!empty($host)) {
$manager->purge_host($host);
$tag = $manager->get_cache_tag_prefix();
if (!empty($tag)) {
$manager->purge_tag($tag);
}
//error_log('[CLP] Varnish Cache purged');
} else {
error_log('[CLP] HTTP_HOST not available');
}
} else {
error_log('[CLP] ClpVarnishCacheManager class not found');
}
}
// AJAX-Hook für Bricks Save
add_action('wp_ajax_bricks_save_post', 'clear_varnish_cache_on_save');
function clear_varnish_cache_on_save() {
clp_clear_varnish_cache();
}
// Classic Editor / Gutenberg Save
add_action('save_post', 'clear_varnish_cache_on_standard_save', 20, 3);
function clear_varnish_cache_on_standard_save($post_ID, $post, $update) {
clp_clear_varnish_cache();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment