prevent regenerate image filter loop

This commit is contained in:
Ron Rennick 2020-08-25 12:53:41 -03:00
parent 3732736029
commit ae96a828ec
1 changed files with 10 additions and 1 deletions

View File

@ -241,7 +241,16 @@ class WC_Regenerate_Images_Request extends WC_Background_Process {
* @return array
*/
public function adjust_intermediate_image_sizes( $sizes ) {
return apply_filters( 'woocommerce_regenerate_images_intermediate_image_sizes', array( 'woocommerce_thumbnail', 'woocommerce_gallery_thumbnail', 'woocommerce_single' ) );
// Prevent a filter loop.
$unfiltered_sizes = array( 'woocommerce_thumbnail', 'woocommerce_gallery_thumbnail', 'woocommerce_single' );
static $in_filter = false;
if ( $in_filter ) {
return $unfiltered_sizes;
}
$in_filter = true;
$filtered_sizes = apply_filters( 'woocommerce_regenerate_images_intermediate_image_sizes', $unfiltered_sizes );
$in_filter = false;
return $filtered_sizes;
}
/**