Skip to content

Instantly share code, notes, and snippets.

@octalmage
Created June 14, 2016 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save octalmage/1fbc8f2e792d7c3c9365b0fae944e4cf to your computer and use it in GitHub Desktop.
Save octalmage/1fbc8f2e792d7c3c9365b0fae944e4cf to your computer and use it in GitHub Desktop.
Automatically purge object cache
<?php
/*
Plugin Name: Automatically purge object cache
Description: Automatically purge object cache on post changes.
*/
foreach ( array( 'trashed_post', 'delete_post', 'edit_post', 'publish_page', 'publish_post', 'save_post' ) as $hook ) {
add_action( $hook, 'wp_cache_flush' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment