function template_caching_fix( WP_Screen $current_screen ) {
if ( ! in_array( $current_screen->base, array( 'post', 'edit', 'theme-editor' ), true ) )
return;
$theme = wp_get_theme();
if ( ! $theme )
return;
$cache_hash = md5( $theme->get_theme_root() . '/' . $theme->get_stylesheet() );
$label = sanitize_key( 'files_' . $cache_hash . '-' . $theme->get( 'Version' ) );
$transient_key = substr( $label, 0, 29 ) . md5( $label );
delete_transient( $transient_key );
}
add_action( 'current_screen', 'template_caching_fix' );
Related