do not use image size cache while in customizer (#38875)

Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
Ron Rennick 2023-06-27 18:50:51 -03:00 committed by GitHub
parent b0ae9dac27
commit 4476129595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
do not use image size cache while in customizer

View File

@ -927,7 +927,7 @@ function wc_get_theme_support( $prop = '', $default = null ) {
*/
function wc_get_image_size( $image_size ) {
$cache_key = 'size-' . ( is_array( $image_size ) ? implode( '-', $image_size ) : $image_size );
$size = wp_cache_get( $cache_key, 'woocommerce' );
$size = ! is_customize_preview() ? wp_cache_get( $cache_key, 'woocommerce' ) : false;
if ( $size ) {
return $size;
@ -983,8 +983,11 @@ function wc_get_image_size( $image_size ) {
$size = apply_filters( 'woocommerce_get_image_size_' . $image_size, $size );
wp_cache_set( $cache_key, $size, 'woocommerce' );
if ( is_customize_preview() ) {
wp_cache_delete( $cache_key, 'woocommerce' );
} else {
wp_cache_set( $cache_key, $size, 'woocommerce' );
}
return $size;
}