From a8de6cef2bd39052cbd8f69b25a7e0528ec07026 Mon Sep 17 00:00:00 2001 From: Neil Pie Date: Thu, 7 Feb 2013 13:41:36 +0000 Subject: [PATCH 1/2] preventing old image size options from being lost on upgrade --- .../updates/woocommerce-update-2.0.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/admin/includes/updates/woocommerce-update-2.0.php b/admin/includes/updates/woocommerce-update-2.0.php index 6080bea4eb2..6e5b3b86d3b 100644 --- a/admin/includes/updates/woocommerce-update-2.0.php +++ b/admin/includes/updates/woocommerce-update-2.0.php @@ -296,4 +296,25 @@ foreach ( $order_tax_rows as $order_tax_row ) { unset( $tax_amount ); } } -} \ No newline at end of file +} + +// Grab the pre 2.0 Image options and use to populate the new image options settings, +// cleaning up afterwards like nice people do + +foreach ( array( 'catalog', 'single', 'thumbnail' ) as $value ) { + + $old_settings = array_filter( array( + 'width' => get_option( 'woocommerce_' . $value . '_image_width' ), + 'height' => get_option( 'woocommerce_' . $value . '_image_height' ), + 'crop' => get_option( 'woocommerce_' . $value . '_image_crop' ) + ) ); + + if ( ! empty( $old_settings ) ){ + + update_option( 'shop_' . $value . '_image_size', $old_settings ) ; + delete_option( 'woocommerce_' . $value . '_image_width' ); + delete_option( 'woocommerce_' . $value . '_image_height' ); + delete_option( 'woocommerce_' . $value . '_image_crop' ); + + } +} From 48d3a1e4379a4c8dfe844d7167dd50fe44b1c36a Mon Sep 17 00:00:00 2001 From: Neil Pie Date: Thu, 7 Feb 2013 13:55:23 +0000 Subject: [PATCH 2/2] only delete the old options if we successfully update --- admin/includes/updates/woocommerce-update-2.0.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/admin/includes/updates/woocommerce-update-2.0.php b/admin/includes/updates/woocommerce-update-2.0.php index 6e5b3b86d3b..1632bd97caa 100644 --- a/admin/includes/updates/woocommerce-update-2.0.php +++ b/admin/includes/updates/woocommerce-update-2.0.php @@ -309,9 +309,8 @@ foreach ( array( 'catalog', 'single', 'thumbnail' ) as $value ) { 'crop' => get_option( 'woocommerce_' . $value . '_image_crop' ) ) ); - if ( ! empty( $old_settings ) ){ + if ( ! empty( $old_settings ) && update_option( 'shop_' . $value . '_image_size', $old_settings ) ){ - update_option( 'shop_' . $value . '_image_size', $old_settings ) ; delete_option( 'woocommerce_' . $value . '_image_width' ); delete_option( 'woocommerce_' . $value . '_image_height' ); delete_option( 'woocommerce_' . $value . '_image_crop' );