query("DROP TABLE IF EXISTS {$wpdb->prefix}{$aiflt_table}"); } // 2. Every option and transient with the plugin's own "aiflt_" prefix, including // the monthly AI usage counters and the rate-limit transients. $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like('aiflt_') . '%', $wpdb->esc_like('_transient_aiflt_') . '%', $wpdb->esc_like('_transient_timeout_aiflt_') . '%' ) ); // Each admin's answer to the one-time review request. delete_metadata('user', 0, 'aiflt_review_ask', '', true); // 3. The tracking session and traffic source stored on orders. $aiflt_hpos_meta = $wpdb->prefix . 'wc_orders_meta'; $aiflt_has_hpos = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $aiflt_hpos_meta)) === $aiflt_hpos_meta; foreach (['_aiflt_session_id', '_aiflt_source', '_aiflt_review_due', '_aiflt_review_sent'] as $aiflt_meta_key) { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s", $aiflt_meta_key)); if ($aiflt_has_hpos) { $wpdb->query($wpdb->prepare("DELETE FROM {$aiflt_hpos_meta} WHERE meta_key = %s", $aiflt_meta_key)); } } wp_cache_flush();