query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'affiliate_links%';" ); // Delete posts + data $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( '$post_type' );" ); $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); // Delete terms + data $taxonomy = Affiliate_Links::$taxonomy; $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); if ( $terms ) { foreach ( $terms as $term ) { $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); } } $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );