• Resolved Mikey

    (@mikeyhash)


    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 doesn’t, as I get the error of such class not being found).

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    fire a do_action( 'litespeed_purge_all' ); in your code ought do it

    Thread Starter Mikey

    (@mikeyhash)

    Hi @qtwrk,

    Thank you for the response, but I’m afraid you misunderstood my question.

    So, let’s 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 it’s clearer now.

    Thank you.

    Plugin Support qtwrk

    (@qtwrk)

    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' );

    • This reply was modified 3 years, 7 months ago by qtwrk.
    Thread Starter Mikey

    (@mikeyhash)

    @qtwrk, perfect, that’s exactly what I wanted.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to access “Purge” class in a custom plugin function?’ is closed to new replies.