From 66e65cf7bffa4b70640f5c175218b93992954547 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 14 Feb 2018 11:38:18 +0000 Subject: [PATCH] Disable image regen if photon is being used. --- .../api/class-wc-rest-system-status-tools-controller.php | 5 +++++ includes/class-wc-regenerate-images.php | 2 +- includes/class-woocommerce.php | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/api/class-wc-rest-system-status-tools-controller.php b/includes/api/class-wc-rest-system-status-tools-controller.php index 6f951026ff0..5ca6b094c8f 100644 --- a/includes/api/class-wc-rest-system-status-tools-controller.php +++ b/includes/api/class-wc-rest-system-status-tools-controller.php @@ -182,6 +182,11 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller { ) ); + // Jetpack does the image resizing heavy lifting so you don't have to. + if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) { + unset( $tools['regenerate_thumbnails'] ); + } + return apply_filters( 'woocommerce_debug_tools', $tools ); } diff --git a/includes/class-wc-regenerate-images.php b/includes/class-wc-regenerate-images.php index 94ffaec9267..e3948b2127d 100644 --- a/includes/class-wc-regenerate-images.php +++ b/includes/class-wc-regenerate-images.php @@ -325,4 +325,4 @@ class WC_Regenerate_Images { } } -add_action( 'init', array( 'WC_Regenerate_Images', 'init' ) ); +WC_Regenerate_Images::init(); diff --git a/includes/class-woocommerce.php b/includes/class-woocommerce.php index 8da28dee7b0..f70574cc0f5 100644 --- a/includes/class-woocommerce.php +++ b/includes/class-woocommerce.php @@ -325,7 +325,6 @@ final class WooCommerce { include_once WC_ABSPATH . 'includes/class-wc-discounts.php'; include_once WC_ABSPATH . 'includes/class-wc-cart-totals.php'; include_once WC_ABSPATH . 'includes/customizer/class-wc-shop-customizer.php'; - include_once WC_ABSPATH . 'includes/class-wc-regenerate-images.php'; /** * Data stores - used to store and retrieve CRUD object data from the database. @@ -482,6 +481,11 @@ final class WooCommerce { $this->load_webhooks(); + // Unless Jetpack Photon is running, let's include our regenerate thumbnails class. + if ( ! class_exists( 'Jetpack' ) || ! Jetpack::is_module_active( 'photon' ) ) { + include_once WC_ABSPATH . 'includes/class-wc-regenerate-images.php'; + } + // Init action. do_action( 'woocommerce_init' ); }