Last active
August 23, 2018 09:59
-
-
Save hatsumatsu/2ece512c520513897efb527b1e2bc20f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Flush W3TC page cache when custom post types are updated. | |
*/ | |
function flushCustomPostTypesPageCache( $post_id ) { | |
$custom_post_types = array( | |
'post_type' => true | |
); | |
if( array_key_exists( get_post_type( $post_id ), $custom_post_types ) ) { | |
if( defined( 'W3TC' ) ) { | |
w3tc_pgcache_flush(); | |
w3tc_dbcache_flush(); | |
} | |
} | |
} | |
add_action( 'save_post', 'flushCustomPostTypesPageCache', 1000, 1 ); | |
add_action( 'edit_post', 'flushCustomPostTypesPageCache', 1000, 1 ); | |
add_action( 'delete_post', 'flushCustomPostTypesPageCache', 1000, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment