patronage / bubs-next

Headless Wordpress + Next.js Project scaffolding
https://bubs-next.vercel.app
MIT License
37 stars 10 forks source link

Clear GraphCDN cache on Wordpress updates/page passwords #234

Open chrisherold opened 2 years ago

chrisherold commented 2 years ago

Currently in the webhooks.php helper there's a wordpress filter to clear the GraphCDN cache on publish. However, we've run into some issues where the post is updated (e.g. from publish to trash or private) and the cached version of the published paged is still served. Updating the filter from 'publish_' . $post_type to transition_post_status should better clear the cache.

Additionally, when a page password is set/removed on a page the page status in Wordpress does not change, but we still want to clear the cache so that the password dialog is correctly set or removed on the public facing page. We can use the pre_post_update Wordpress filter to get the current page password and compare it to the incoming password from $data and clear the cache if those values do not match