Forked from tangrufus/clear-beaver-builder-and-wp-rocket-caches-whenever-a-post-type-changed.php
Created
December 10, 2020 08:43
-
-
Save VelichkoAlexander/7ba3b71ac5af9a1e4ae036fea480b1b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('save_post', function($id, $post, $update): void { | |
// Skip if wp rocket is not activated. | |
if (! function_exists('rocket_clean_domain')) { | |
return; | |
} | |
if (! $update) { | |
return; | |
} | |
$postType = get_post_type($id); | |
// TODO: Change to the correct post type! | |
if ('post' !== $postType) { | |
return; | |
} | |
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