Advertisement
swte

Clean post cache

Feb 8th, 2023 (edited)
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. // Swift Performance 2
  2. add_action('swift_performance_after_clear_post_cache', function($post_id){
  3.     clean_post_cache($post_id);
  4. });
  5.  
  6. add_action('swift_performance_after_clear_all_cache', function(){
  7.     wp_cache_delete( 'all_page_ids', 'posts' );
  8. });
  9.  
  10. // Swift Performance AI
  11. add_action('swift3_invalidate_cache', 'swiftai_clean_post_cache');
  12. add_action('swift3_purge_cache', 'swiftai_clean_post_cache');
  13.  
  14. function swiftai_clean_post_cache($url){
  15.     if (!empty($url)){
  16.         clean_post_cache(url_to_postid($post_id));
  17.     }
  18.     else {
  19.         wp_cache_delete( 'all_page_ids', 'posts' );
  20.     }
  21. });
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement