Skip to content

Instantly share code, notes, and snippets.

@mavas84
mavas84 / gist:a2d07ccf922c46af23ebfc49dc15c13e
Created December 4, 2024 15:02
Prevent cache flush on actions by other themes or plugins
Some plugins flushing page cache all the time and without a reason effectively blocking
page caching functionality.
It's usually done by w3tc_flush_all / w3tc_flush_posts calls.
You may block those by cancelling their functionality by adding hooks to w3tc_preflush_posts / w3tc_preflush_all actions.
W3TC UI buttons send $extras as [ 'ui_action' = 'flush_button' ] value, this one
can be used to still allow flushing by UI button.
Here is the example code: