How to access Purge class in a custom plugin function?




Wordpress LScache Plugin: How to access Purge class in a custom plugin function?

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi, Can you please tell me how to trigger a purge for all pages when a specific function from a custom plugin is executed? In other words, how to access the Purge class, in order to trigger the purge_pages function? (I was expecting something like Litespeed Purge::purge_pages() to work, but it doesnt, as I get the error of such class not being found). Thank you. Hi, fire a do_action( litespeed_purge_all ) in your code ought do it Hi @CacheCrawler, Thank you for the response, but Im afraid you misunderstood my question. So, lets say I have a form on frontend. When the user submits the form, a php function is executed. Now, I want to insert inside that function a trigger for purging all pages (Note: not purge all, but only the pages). Basically I want to call function like Litespeed Purge::purge_pages() inside the function for the submission of the form. Hope its clearer now. Thank you. then use if( defined(LSCWP_V) ) do_action( litespeed_purge_url, https://my.domain.com/my-form ) to purge page by URL , or do_action( litespeed_purge_post, $post_ID ) to purge page by post id if you want to purge all pages that is type page do_action( litespeed_purge_posttype, page ) @CacheCrawler, perfect, thats exactly what I wanted. Thank you.



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference