Delete all usermeta on uninstall with prefix woocommerce_

This commit is contained in:
Shiva Poudel 2018-02-23 10:17:21 +05:45
parent e4bcc1d285
commit 6714658fbc
1 changed files with 3 additions and 5 deletions

View File

@ -51,17 +51,15 @@ if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) {
// 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.