Quantcast
Channel: wp-super-cache – WordPress.org Forums
Viewing all articles
Browse latest Browse all 3480

Junaid Bhura on "[Plugin: WP Super Cache] Problem with SuperCache and Polylang (multiple domains)"

$
0
0

You can use this code in your functions.php file. This will clear the cache for posts when you update it. I'm not sure how the delete all cached pages would work as there are no hooks:

// Fix Polylang WP Super Cache problem
function jb_clear_polylang_super_cache( $post_ID, $post_after, $post_before ) {
	if ( ! empty( $post_after ) ) {
		$parsed_url = parse_url( get_permalink( $post_after->ID ) );
		if ( $parsed_url ) {
			global $cache_path;
			$language = pll_get_post_language( $post_after->ID );
			$cache_dir = $cache_path . 'supercache/' . $parsed_url['host'] . $parsed_url['path'];
			$files = get_all_supercache_filenames( $cache_dir );
			if ( $files ) {
				foreach( $files as $cache_file ) {
					prune_super_cache( $cache_dir . $cache_file, true );
				}
			}
		}
	}
}
add_action( 'post_updated', 'jb_clear_polylang_super_cache', 10, 3 );

Viewing all articles
Browse latest Browse all 3480

Trending Articles