From 18d093883e11cf18d6fce4d47f22eda730da9501 Mon Sep 17 00:00:00 2001 From: Eduard Florea Date: Fri, 22 Dec 2023 04:36:13 -0800 Subject: [PATCH] Feature/add revalidate isr for post filter (#660) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nícholas André Co-authored-by: Nícholas André --- .changeset/sweet-gorillas-admire.md | 5 +++++ wp/headless-wp/includes/classes/CacheFlush/CacheFlush.php | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/sweet-gorillas-admire.md diff --git a/.changeset/sweet-gorillas-admire.md b/.changeset/sweet-gorillas-admire.md new file mode 100644 index 000000000..70c5f7069 --- /dev/null +++ b/.changeset/sweet-gorillas-admire.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/headstartwp": patch +--- + +Added - New filter available tenup_headless_wp_revalidate_isr_for_post diff --git a/wp/headless-wp/includes/classes/CacheFlush/CacheFlush.php b/wp/headless-wp/includes/classes/CacheFlush/CacheFlush.php index 36f4a3542..c60d0ea73 100644 --- a/wp/headless-wp/includes/classes/CacheFlush/CacheFlush.php +++ b/wp/headless-wp/includes/classes/CacheFlush/CacheFlush.php @@ -64,6 +64,12 @@ public function trigger_cache_for_post( $post_id, \WP_Post $post, $update ) { return; } + // check if we should revalidate isr for this post particularly + $should_revalidate_isr = apply_filters( 'tenup_headless_wp_revalidate_isr_for_post', true, $post_id, $post ); + if ( ! $should_revalidate_isr ) { + return; + } + /** * Checks whether the revalidation should run in a cron job. *