Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme...
File: uninstall.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WooCommerce Uninstall
[2] Fix | Delete
*
[3] Fix | Delete
* Uninstalling WooCommerce deletes user roles, pages, tables, and options.
[4] Fix | Delete
*
[5] Fix | Delete
* @package WooCommerce\Uninstaller
[6] Fix | Delete
* @version 2.3.0
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
[10] Fix | Delete
[11] Fix | Delete
global $wpdb, $wp_version, $wc_uninstalling_plugin;
[12] Fix | Delete
[13] Fix | Delete
$wc_uninstalling_plugin = true;
[14] Fix | Delete
[15] Fix | Delete
// Clear WordPress cron events.
[16] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_scheduled_sales' );
[17] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
[18] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_cleanup_sessions' );
[19] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_cleanup_personal_data' );
[20] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_cleanup_logs' );
[21] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_geoip_updater' );
[22] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' );
[23] Fix | Delete
wp_clear_scheduled_hook( 'woocommerce_cleanup_rate_limits' );
[24] Fix | Delete
wp_clear_scheduled_hook( 'wc_admin_daily' );
[25] Fix | Delete
wp_clear_scheduled_hook( 'generate_category_lookup_table' );
[26] Fix | Delete
wp_clear_scheduled_hook( 'wc_admin_unsnooze_admin_notes' );
[27] Fix | Delete
[28] Fix | Delete
if ( class_exists( ActionScheduler::class ) && ActionScheduler::is_initialized() && function_exists( 'as_unschedule_all_actions' ) ) {
[29] Fix | Delete
as_unschedule_all_actions( 'woocommerce_scheduled_sales' );
[30] Fix | Delete
as_unschedule_all_actions( 'woocommerce_cancel_unpaid_orders' );
[31] Fix | Delete
as_unschedule_all_actions( 'woocommerce_cleanup_sessions' );
[32] Fix | Delete
as_unschedule_all_actions( 'woocommerce_cleanup_personal_data' );
[33] Fix | Delete
as_unschedule_all_actions( 'woocommerce_cleanup_logs' );
[34] Fix | Delete
as_unschedule_all_actions( 'woocommerce_geoip_updater' );
[35] Fix | Delete
as_unschedule_all_actions( 'woocommerce_tracker_send_event' );
[36] Fix | Delete
as_unschedule_all_actions( 'woocommerce_cleanup_rate_limits' );
[37] Fix | Delete
as_unschedule_all_actions( 'wc_admin_daily' );
[38] Fix | Delete
as_unschedule_all_actions( 'generate_category_lookup_table' );
[39] Fix | Delete
as_unschedule_all_actions( 'wc_admin_unsnooze_admin_notes' );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
/*
[43] Fix | Delete
* Only remove ALL product and page data if WC_REMOVE_ALL_DATA constant is set to true in user's
[44] Fix | Delete
* wp-config.php. This is to prevent data loss when deleting the plugin from the backend
[45] Fix | Delete
* and to ensure only the site owner can perform this action.
[46] Fix | Delete
*/
[47] Fix | Delete
if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) {
[48] Fix | Delete
// Load WooCommerce so we can access the container, install routines, etc, during uninstall.
[49] Fix | Delete
require_once __DIR__ . '/includes/class-wc-install.php';
[50] Fix | Delete
[51] Fix | Delete
// Roles + caps.
[52] Fix | Delete
WC_Install::remove_roles();
[53] Fix | Delete
[54] Fix | Delete
// Pages.
[55] Fix | Delete
wp_trash_post( get_option( 'woocommerce_shop_page_id' ) );
[56] Fix | Delete
wp_trash_post( get_option( 'woocommerce_cart_page_id' ) );
[57] Fix | Delete
wp_trash_post( get_option( 'woocommerce_checkout_page_id' ) );
[58] Fix | Delete
wp_trash_post( get_option( 'woocommerce_myaccount_page_id' ) );
[59] Fix | Delete
wp_trash_post( get_option( 'woocommerce_edit_address_page_id' ) );
[60] Fix | Delete
wp_trash_post( get_option( 'woocommerce_view_order_page_id' ) );
[61] Fix | Delete
wp_trash_post( get_option( 'woocommerce_change_password_page_id' ) );
[62] Fix | Delete
wp_trash_post( get_option( 'woocommerce_logout_page_id' ) );
[63] Fix | Delete
[64] Fix | Delete
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_attribute_taxonomies';" ) ) {
[65] Fix | Delete
$wc_attributes = array_filter( (array) $wpdb->get_col( "SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies;" ) );
[66] Fix | Delete
} else {
[67] Fix | Delete
$wc_attributes = array();
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// Tables.
[71] Fix | Delete
WC_Install::drop_tables();
[72] Fix | Delete
[73] Fix | Delete
// Delete options.
[74] Fix | Delete
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';" );
[75] Fix | Delete
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'widget\_woocommerce\_%';" );
[76] Fix | Delete
[77] Fix | Delete
// Delete usermeta.
[78] Fix | Delete
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'woocommerce\_%';" );
[79] Fix | Delete
[80] Fix | Delete
// Delete our data from the post and post meta tables, and remove any additional tables we created.
[81] Fix | Delete
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" );
[82] Fix | Delete
$wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
[83] Fix | Delete
[84] Fix | Delete
$wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type IN ( 'order_note' );" );
[85] Fix | Delete
$wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" );
[86] Fix | Delete
[87] Fix | Delete
// Delete terms if > WP 4.2 (term splitting was added in 4.2).
[88] Fix | Delete
if ( version_compare( $wp_version, '4.2', '>=' ) ) {
[89] Fix | Delete
// Delete term taxonomies.
[90] Fix | Delete
foreach ( array( 'product_cat', 'product_tag', 'product_shipping_class', 'product_type' ) as $_taxonomy ) {
[91] Fix | Delete
$wpdb->delete(
[92] Fix | Delete
$wpdb->term_taxonomy,
[93] Fix | Delete
array(
[94] Fix | Delete
'taxonomy' => $_taxonomy,
[95] Fix | Delete
)
[96] Fix | Delete
);
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
// Delete term attributes.
[100] Fix | Delete
foreach ( $wc_attributes as $_taxonomy ) {
[101] Fix | Delete
$wpdb->delete(
[102] Fix | Delete
$wpdb->term_taxonomy,
[103] Fix | Delete
array(
[104] Fix | Delete
'taxonomy' => 'pa_' . $_taxonomy,
[105] Fix | Delete
)
[106] Fix | Delete
);
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
// Delete orphan relationships.
[110] Fix | Delete
$wpdb->query( "DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;" );
[111] Fix | Delete
[112] Fix | Delete
// Delete orphan terms.
[113] Fix | Delete
$wpdb->query( "DELETE t FROM {$wpdb->terms} t LEFT JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
[114] Fix | Delete
[115] Fix | Delete
// Delete orphan term meta.
[116] Fix | Delete
if ( ! empty( $wpdb->termmeta ) ) {
[117] Fix | Delete
$wpdb->query( "DELETE tm FROM {$wpdb->termmeta} tm LEFT JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
// Clear any cached data that has been removed.
[122] Fix | Delete
wp_cache_flush();
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
unset( $wc_uninstalling_plugin );
[126] Fix | Delete
[127] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function