How to purge ls cache by wp-cron?




Wordpress LScache Plugin: How to purge ls cache by wp-cron?


We tried this code, but it doesnt 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 lets 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() Expand 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? This topic was modified 2 weeks, 1 day ago by Christian Kormos. This topic was modified 2 weeks, 1 day ago by Christian Kormos. please use this if deinfed(LSCWP_V) do_action( litespeed_purge_all ) I tried your code, it had some typo: if (defined(LSCWP_V)) do_action( litespeed_purge_all ) The code doesnt 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 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 We use this plugin: https://www.litespeedtech.com https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration Are you sure its your plugin? : ) 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 lets 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) Expand may I know if you are running on wp 6.1 ? Yes, were running it on WP 6.1 already. could you please try edit the file as this commit ? see if it helps Could you provide the code with mine becuase I dont know what do you mean exactly from that commit. Thanks in advance. Our main problem we cant see the future post in time. In our case the future post is a custom post type. Thats why we tried to purge litespeed cache, because this action helped to appear them. 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,