Skip to content

Commit

Permalink
Delete all usermeta on uninstall with prefix woocommerce_
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiva Poudel committed Feb 23, 2018
1 parent e4bcc1d commit 6714658
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,15 @@
// Delete options.
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';" );

// Delete usermeta.
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key 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 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" );

// Delete user meta data.
foreach ( array( 'woocommerce_keys_per_page', 'woocommerce_webhooks_per_page' ) as $meta_key ) {
delete_metadata( 'user', 0, $meta_key, '', true );
}

// Delete terms if > WP 4.2 (term splitting was added in 4.2).
if ( version_compare( $wp_version, '4.2', '>=' ) ) {
// Delete term taxonomies.
Expand Down

0 comments on commit 6714658

Please sign in to comment.