Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tangrufus/f5189a1d0177dee23d013c4f7741571e to your computer and use it in GitHub Desktop.
Save tangrufus/f5189a1d0177dee23d013c4f7741571e to your computer and use it in GitHub Desktop.
<?php
add_action('save_post', function($id, $post, $update): void {
if (! $update) {
return;
}
$postType = get_post_type($id);
// TODO: Change to the correct post type!
if ('post' !== $postType) {
return;
}
// Skip if beaver builder is not activated.
if (method_exists('FLBuilderModel','delete_asset_cache_for_all_posts')) {
\FLBuilderModel::delete_asset_cache_for_all_posts();
}
// Skip if wp rocket is not activated.
if (function_exists('rocket_clean_domain')) {
\rocket_clean_domain();
}
// TODO: Remove after testing!
wp_die('Purge Triggered');
}, PHP_INT_MAX, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment