[Plugin: WP Widget Cache] Widget Cache Remove Function
-
Hello all,
I am trying to use WP-Widget-Cache to cache a specific part of my sidebar while keeping everything else dynamic. I surrounded the code I want cached with the following:
<?php while($widget_cache->wcache->save($widget_cache->get_widget_cache_key("12344321"),9999, array())) { ?> THE CODE I WANT CACHED <?php } ?>
This caches the code just fine. =) Now, I want the cache to be cleared each time certain actions occur (comment is posted, post is published, etc.)
This is what I added to my functions.php file. The custom_clearwcache function should clear the cached code based on the ID:
function custom_clearwcache(){widget_cache_remove("12344321");}
The following loop executes the custom_clearwcache function for all the actions I require (adding a link, deleting a link, etc.)
$custom_action_arr=array("add_link", "delete_link", "edit_link", "add_category", "delete_category", "publish_page","publish_post","comment_post","comment_post","deleted_post", "edit_comment","delete_comment","wp_set_comment_status"); foreach($custom_action_arr as $ca) { add_action('ca', 'custom_clearwcache'); }
I tried adding a dummy comment and adding a test link to my blogroll, but neither of those actions would clear the cache. Is there some syntax error I’ve committed or something I’ve overlooked entirely regarding the add_action function?
https://www.ads-software.com/extend/plugins/wp-widget-cache/
- The topic ‘[Plugin: WP Widget Cache] Widget Cache Remove Function’ is closed to new replies.