@korchiy Sorry at the moment this is not a feature yet, you can only purge the full cache when you click purge cache.
Is the force deleting the .html, .php and .gz files of the required directory in WP Optimize cache folder equal with the partial clearing cache for this page?
What will appear if I delete them?
@korchiy If you delete the files the cache files will be deleted and it will generate new files when you visit the pages.
I searched the source of the WP Optimize plugin and found the function delete_cache_by_url in the WPO_Page_Cache class.
So to clean cache for the different language, I wrote the following code. Maybe it will be useful for somebody else
function wp_optimize_dlang_cache_clean($new_status, $old_status, $post) {
if(in_array($post->post_type, ['post', 'page']) && $new_status === 'publish') {
if(function_exists('pll_get_post_language') && function_exists('pll_default_language')) {
$post_lang = pll_get_post_language($post->ID); // fr
$def_lang = pll_default_language(); // en
if($post_lang && $def_lang && $post_lang != $def_lang) {
$url = home_url() . '/' . $post_lang . '/';
if(class_exists('WPO_Page_Cache')) {
WPO_Page_Cache::delete_cache_by_url($url, false);
}
}
}
}
}
add_action('transition_post_status', 'wp_optimize_dlang_cache_clean', 10, 3);
pll_get_post_language and pll_default_language functions are from the Polylang plugin to get the current post language and the default site language.
@korchiy Thanks for sharing the code, I’ll share the same with our development team, so it can be implemented in future release
Hello.
Do you think it can somehow be applied to woocomerce products?
I have been looking for a solution for clearing the cache of a translated product for a long time.
And everyone throws up their hands.
Only the main language is cleared, the other language shows the wrong price or balances.
They say to clear the cache manually .. But there are more than 5000 products.
I’m sure there is a similar hook for products 🙂
Have you tried my code? If I’m not mistaken, the WooCommerce product pages are the common “post” pages. So I think my code could work with them too. Of course, it needs to be tested in practice.
Now I have installed Polylang and need to prepare the translation.
And I will test.
Should this code be added to function.php?
Should this code be added to function.php?
Yes, you need it in the functions.php to work.
Tested tested …. Nothing worked.
Changed the hosting everything worked out 🙂
Thanks a lot for the hook.
It’s strange, the code doesn’t depend on hosting.