• Resolved Krisztian Kormos

    (@darkchris)


    We tried this code, but it doesn’t seems to affect.

    // Remove srcset
    add_filter('wp_calculate_image_srcset_meta', '__return_false');
    
    // Register a new cron schedule with 86400 seconds interval
    add_filter('cron_schedules', 'add_ligetpost_cron_schedule');
    function add_ligetpost_cron_schedule($schedules)
    {
    	if (!isset($schedules["ligetpost_daily"])) {
    		$schedules['ligetpost_daily'] = array(
    			'interval' => 86400,
    			'display'  => esc_html__('Ligetpost Every Day'),
    		);
    	}
    	return $schedules;
    }
    
    if (!wp_next_scheduled('ligetpost_daily')) {
    	wp_schedule_event(strtotime('00:06:00 Europe/Budapest'), 'ligetpost_daily', 'ligetpost_daily');
    }
    
    // Now let's hook it up with our function
    add_action('ligetpost_daily', 'clear_litespeed_cache');
    
    function clear_litespeed_cache()
    {
    	if (class_exists('\LiteSpeed\Purge')) {
    		\LiteSpeed\Purge::purge_all();
    	}
    }

    After that I checked your plugin and I found this code.

    $this->_purge_all_lscache();

    How could I call this function in my function.php?

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

    (@qtwrk)

    please use this

    if deinfed('LSCWP_V'){
    do_action( 'litespeed_purge_all' );
    }
    Thread Starter Krisztian Kormos

    (@darkchris)

    I tried your code, it had some typo:

    if (defined('LSCWP_V')) {
    do_action( 'litespeed_purge_all' );
    }

    The code doesn’t work.

    I would like to do the same effect like the attached function do, but with wp-cron.
    https://freeimage.host/i/kep-2022-11-15-115336291.H9qVBON

    Plugin Support qtwrk

    (@qtwrk)

    Must not have enough coffee that day for that typo

    that api is doing exactly as that drop-down menu purge

    try tail the debug log, see if that api was called

    • This reply was modified 1 year, 5 months ago by qtwrk.
    Thread Starter Krisztian Kormos

    (@darkchris)

    We use this plugin:
    https://www.litespeedtech.com
    https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration

    Are you sure it’s your plugin? : )

    Thread Starter Krisztian Kormos

    (@darkchris)

    Could you try this code on your own server?
    I use wp control plugin and I can run it immediately, but had no affect.

    // Remove srcset
    add_filter('wp_calculate_image_srcset_meta', '__return_false');
    
    // Register a new cron schedule with 86400 seconds interval
    add_filter('cron_schedules', 'add_ligetpost_cron_schedule');
    function add_ligetpost_cron_schedule($schedules)
    {
    	if (!isset($schedules["ligetpost_daily"])) {
    		$schedules['ligetpost_daily'] = array(
    			'interval' => 86400,
    			'display'  => esc_html__('Ligetpost Every Day'),
    		);
    	}
    	return $schedules;
    }
    
    // Schedule our custom job, I am going to set it to execute everyday at 00:00:05 (GMT+8)
    // This timing is to ensure the 1st visitor visit my site will be after a new day based on my promotion behaviour (start date + end date)
    if (!wp_next_scheduled('ligetpost_daily')) {
    	wp_schedule_event(strtotime('00:06:00 Europe/Budapest'), 'ligetpost_daily', 'ligetpost_daily');
    }
    
    // Now let's hook it up with our function
    add_action('ligetpost_daily', 'clear_litespeed_cache');
    
    function clear_litespeed_cache()
    {
    	if (defined('LSCWP_V')) {
    		do_action('litespeed_purge_all');
    	}
    }
    Plugin Support qtwrk

    (@qtwrk)

    may I know if you are running on wp 6.1 ?

    Thread Starter Krisztian Kormos

    (@darkchris)

    Yes, we’re running it on WP 6.1 already.

    Plugin Support qtwrk

    (@qtwrk)

    could you please try edit the file as this commit ?

    see if it helps

    Thread Starter Krisztian Kormos

    (@darkchris)

    Could you provide the code with mine becuase I don’t know what do you mean exactly from that commit.

    Thanks in advance.

    Thread Starter Krisztian Kormos

    (@darkchris)

    Our main problem we can’t see the future post in time.
    In our case the future post is a custom post type.

    That’s why we tried to purge litespeed cache, because this action helped to appear them.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    please go to toolbox -> beta test , put this link

    https://github.com/litespeedtech/lscache_wp/commit/cc231479bdf3c36712267a82898737fc2fe9a646

    then upgrade , see how it goes

    it works now on my test site

    best regards,

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How to purge ls cache by wp-cron?’ is closed to new replies.