woocommerce/uninstall.php

65 lines
2.9 KiB
PHP
Raw Normal View History

2011-12-19 15:44:00 +00:00
<?php
/**
* WooCommerce Uninstall
2012-08-14 15:30:23 +00:00
*
* Uninstalling WooCommerce deletes user roles, pages, tables, and options.
2011-12-19 15:44:00 +00:00
*
* @author WooThemes
* @category Core
* @package WooCommerce/Uninstaller
* @version 2.3.0
2011-12-19 15:44:00 +00:00
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
2011-12-19 15:44:00 +00:00
global $wpdb;
wp_clear_scheduled_hook( 'woocommerce_scheduled_sales' );
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
wp_clear_scheduled_hook( 'woocommerce_cleanup_sessions' );
wp_clear_scheduled_hook( 'woocommerce_geoip_updater' );
wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' );
$status_options = get_option( 'woocommerce_status_options', array() );
if ( ! empty( $status_options['uninstall_data'] ) ) {
2015-10-31 18:55:15 +00:00
// Roles + caps.
include_once( 'includes/class-wc-install.php' );
WC_Install::remove_roles();
2015-10-31 18:55:15 +00:00
// 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' ) );
2015-10-31 18:55:15 +00:00
// Tables.
2015-05-15 21:20:49 +00:00
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_api_keys" );
$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" );
2016-01-08 14:53:24 +00:00
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zone_methods" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zone_locations" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zones" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_sessions" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_payment_tokens" );
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_payment_tokenmeta" );
2015-10-31 18:55:15 +00:00
// Delete options.
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';");
2015-10-31 18:55:15 +00:00
// Delete posts + data.
2014-07-11 11:43:42 +00:00
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" );
2015-03-27 18:29:01 +00:00
$wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.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" );
}