From 90ba359ef96ce11cda8b432931a2ae02b86e6544 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 23 Oct 2013 17:21:03 +0100 Subject: [PATCH] Uninstall option Closes #3968. Change option for #3992 --- .../views/html-admin-page-status-tools.php | 55 +++++++++++-------- includes/class-wc-template-loader.php | 5 +- uninstall.php | 17 +++++- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/includes/admin/views/html-admin-page-status-tools.php b/includes/admin/views/html-admin-page-status-tools.php index 2a549108cd1..83757f08b94 100644 --- a/includes/admin/views/html-admin-page-status-tools.php +++ b/includes/admin/views/html-admin-page-status-tools.php @@ -1,6 +1,6 @@
- + 0, 'template_debug_mode' => 0 ) ); ?> @@ -8,28 +8,39 @@ - $tool ) { ?> - - - + + + + + + + - - - - - - +

+ +

+ + + + + +
-

- - + $tool ) { ?> +

+

+ + +

+
+

+

-
-

- -

-

- -

-
+

+ +

+

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

+

diff --git a/includes/class-wc-template-loader.php b/includes/class-wc-template-loader.php index 2088b4b797f..d5e851727f2 100644 --- a/includes/class-wc-template-loader.php +++ b/includes/class-wc-template-loader.php @@ -62,8 +62,9 @@ class WC_Template_Loader { } if ( $file ) { - $template = locate_template( $find ); - if ( ! $template || ( get_option( 'woocommerce_status_options' ) && current_user_can( 'manage_options' ) ) ) + $template = locate_template( $find ); + $status_options = get_option( 'woocommerce_status_options', array() ); + if ( ! $template || ( ! empty( $status_options['template_debug_mode'] ) && current_user_can( 'manage_options' ) ) ) $template = WC()->plugin_path() . '/templates/' . $file; } diff --git a/uninstall.php b/uninstall.php index 2b89fa1d703..4c42dfba2b8 100644 --- a/uninstall.php +++ b/uninstall.php @@ -7,12 +7,15 @@ * @author WooThemes * @category Core * @package WooCommerce/Uninstaller - * @version 1.6.4 + * @version 2.1.0 */ -if( !defined('WP_UNINSTALL_PLUGIN') ) exit(); +if( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) + exit(); global $wpdb, $wp_roles; +$status_options = get_option( 'woocommerce_status_options', array() ); + // Roles + caps $installer = include( 'includes/class-wc-install.php' ); $installer->remove_roles(); @@ -41,4 +44,12 @@ $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_%';"); \ No newline at end of file +$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce_%';"); + +if ( ! empty( $status_options['uninstall_data'] ) ) { + // Delete posts + data + $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order' );" ); + $wpdb->query( "DELETE FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE wp.ID IS NULL;" ); + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_order_items" ); + $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_order_itemmeta" ); +} \ No newline at end of file