2011-12-19 15:44:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce Uninstall
|
2012-08-14 15:30:23 +00:00
|
|
|
*
|
2011-12-19 15:44:00 +00:00
|
|
|
* Uninstalling WooCommerce deletes user roles, options, tables, and pages.
|
|
|
|
*
|
2012-08-14 15:30:23 +00:00
|
|
|
* @author WooThemes
|
|
|
|
* @category Core
|
|
|
|
* @package WooCommerce/Uninstaller
|
2013-10-23 16:21:03 +00:00
|
|
|
* @version 2.1.0
|
2011-12-19 15:44:00 +00:00
|
|
|
*/
|
2014-08-18 12:45:24 +00:00
|
|
|
if( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
|
2013-10-23 16:21:03 +00:00
|
|
|
exit();
|
2011-12-19 15:44:00 +00:00
|
|
|
|
|
|
|
global $wpdb, $wp_roles;
|
2012-08-14 15:30:23 +00:00
|
|
|
|
2013-10-23 16:21:03 +00:00
|
|
|
$status_options = get_option( 'woocommerce_status_options', array() );
|
|
|
|
|
2012-09-20 15:35:15 +00:00
|
|
|
// Roles + caps
|
2013-08-09 16:11:15 +00:00
|
|
|
$installer = include( 'includes/class-wc-install.php' );
|
|
|
|
$installer->remove_roles();
|
2011-12-19 15:44:00 +00:00
|
|
|
|
|
|
|
// Pages
|
2014-02-14 11:22:00 +00:00
|
|
|
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' ) );
|
2011-12-19 15:44:00 +00:00
|
|
|
|
2012-06-08 10:46:10 +00:00
|
|
|
// mijireh checkout page
|
2012-08-14 15:30:23 +00:00
|
|
|
if ( $mijireh_page = get_page_by_path( 'mijireh-secure-checkout' ) )
|
2014-02-14 11:22:00 +00:00
|
|
|
wp_trash_post( $mijireh_page->ID );
|
2012-06-08 10:46:10 +00:00
|
|
|
|
2011-12-19 15:44:00 +00:00
|
|
|
// Tables
|
2012-04-30 19:50:35 +00:00
|
|
|
$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" );
|
2012-11-30 15:11:19 +00:00
|
|
|
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_tax_rates" );
|
|
|
|
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_tax_rate_locations" );
|
2011-12-19 15:44:00 +00:00
|
|
|
|
|
|
|
// Delete options
|
2013-10-23 16:21:03 +00:00
|
|
|
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce_%';");
|
|
|
|
|
|
|
|
if ( ! empty( $status_options['uninstall_data'] ) ) {
|
|
|
|
// 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' );" );
|
2013-10-23 16:21:03 +00:00
|
|
|
$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" );
|
2014-08-18 12:45:24 +00:00
|
|
|
}
|