Hi @taadike,
I just checked the docs and it appears there is not a public method for easily clearing the ALM cache.
In the add-on there is a alm_delete_full_cache
method that may useful.
You would have to call it via php or Ajax if the action is triggered with javaScript.
You would trigger ALMCache::alm_delete_full_cache()
Let me know if this helps.
This worked, thanks a lot.
Seems like this works only for admins. If a visitor clicks the button then cache is not deleted.
I also found this function and even though I removed this line it still didn’t work for average visitors:
// if (current_user_can( apply_filters(‘alm_custom_user_role’,
public static function alm_delete_full_cache(){
// if (current_user_can( apply_filters('alm_custom_user_role', 'edit_theme_options') )){
$path = ALMCache::alm_get_cache_path();
foreach (new DirectoryIterator($path) as $directory) {
if ($directory->isDot()) continue;
if ($directory->isDir()){
$path_to_directory = $path . $directory;
self::alm_cache_rmdir($path_to_directory);
}
}
// Hook dispatched after cache has been deleted
do_action('alm_cache_deleted');
return __('Cache deleted successfully', 'ajax-load-more-cache');
// }
wp_die();
}
Any ideas how to make it work for average visitors?
Hey, never mind about this, I have resolved this now 🙂