From 2a472e64e8f87079e622bfac34a84e14b788c17b Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 12 Feb 2015 11:09:13 +0000 Subject: [PATCH] Only run the uninstaller if the "Uninstall on Delete" option is checked in system status. --- .../views/html-admin-page-status-tools.php | 4 +- readme.txt | 1 + uninstall.php | 56 ++++++++++--------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/includes/admin/views/html-admin-page-status-tools.php b/includes/admin/views/html-admin-page-status-tools.php index d0be56e6728..83d9cb0bac2 100644 --- a/includes/admin/views/html-admin-page-status-tools.php +++ b/includes/admin/views/html-admin-page-status-tools.php @@ -53,13 +53,13 @@ if ( ! defined( 'ABSPATH' ) ) { - +

- Delete.', 'woocommerce' ); ?> + Delete.', 'woocommerce' ); ?>

diff --git a/readme.txt b/readme.txt index bd883be2d0b..05a09cb7a0b 100644 --- a/readme.txt +++ b/readme.txt @@ -139,6 +139,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc == Changelog == * Fix - Potential notice with preg_match wildcard search, if used incorrectly. +* Tweak - Only run the uninstaller if the "Uninstall on Delete" option is checked in system status. = 2.3.2 - 12/02/2015 = * Fix - Item meta removal query in order class. diff --git a/uninstall.php b/uninstall.php index ff535b26992..af60f400456 100644 --- a/uninstall.php +++ b/uninstall.php @@ -9,39 +9,41 @@ * @package WooCommerce/Uninstaller * @version 2.3.0 */ -if( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { + +if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { exit; } -global $wpdb; - $status_options = get_option( 'woocommerce_status_options', array() ); -// Roles + caps -include_once( 'includes/class-wc-install.php' ); -WC_Install::remove_roles(); - -// Pages -wp_trash_post( get_option( 'woocommerce_shop_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_cart_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_checkout_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_myaccount_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_edit_address_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_view_order_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_change_password_page_id' ) ); -wp_trash_post( get_option( 'woocommerce_logout_page_id' ) ); - -// Tables -$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_attribute_taxonomies" ); -$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_downloadable_product_permissions" ); -$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_termmeta" ); -$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_tax_rates" ); -$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_tax_rate_locations" ); - -// Delete options -$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce_%';"); - if ( ! empty( $status_options['uninstall_data'] ) ) { + + global $wpdb; + + // Roles + caps + include_once( 'includes/class-wc-install.php' ); + WC_Install::remove_roles(); + + // Pages + wp_trash_post( get_option( 'woocommerce_shop_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_cart_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_checkout_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_myaccount_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_edit_address_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_view_order_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_change_password_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_logout_page_id' ) ); + + // Tables + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_attribute_taxonomies" ); + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_downloadable_product_permissions" ); + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_termmeta" ); + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_tax_rates" ); + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_tax_rate_locations" ); + + // Delete options + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce_%';"); + // Delete posts + data $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" ); $wpdb->query( "DELETE FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE wp.ID IS NULL;" );