Last active
May 16, 2019 08:57
-
-
Save sanzeeb3/ed94371d1f053fdc3e12fc47d052b210 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 cache created by some popular WordPress plugins in a specific page. | |
* | |
* @return void. | |
*/ | |
function sa_flush_cache() { | |
$post_id = get_the_ID(); | |
// Flush already set cache by w3total cache plugin. | |
if ( function_exists( 'w3tc_pgcache_flush' ) ) { | |
w3tc_pgcache_flush_post( $post_id ); | |
} | |
// Flush already set cache by wp super cache plugin | |
if ( function_exists( 'wpsc_delete_post_cache' ) ) { | |
wpsc_delete_post_cache( $post_id ); | |
} | |
// Flush already set cache by wp rocket cache plugin | |
if ( function_exists( 'rocket_clean_post' ) ) { | |
$post_id = get_the_ID(); | |
rocket_clean_post( $post_id ); | |
} | |
} | |
add_action( 'init', 'sa_flush_cache' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment