So I couldn’t find anything so I created this. The only drawback is that it will delete the ‘Uncategorized’ term in the Posts, but I can live with this since it’s just for development purpose.
function delete_all(){
global $wpdb;
$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
$all_post_types = get_post_types();
$all_taxonomies = get_taxonomies();
$all_options = wp_load_alloptions();
foreach ($all_options as $option) {
delete_option($option);
}
foreach ($menus as $menu => $menu_obj) {
wp_delete_nav_menu($menu_obj->term_id);
}
foreach ($all_post_types as $post_type => $post_type_value) {
$temp_posts = get_posts( array('post_type' => $post_type, 'posts_per_page' => -1));
foreach ($temp_posts as $temp_post => $temp_post_value) {
wp_delete_post($temp_post_value->ID);
}
}
remove_theme_mods();
foreach ( $all_taxonomies as $taxonomy ) {
// Prepare & excecute SQL - also deletes Uncategorized
$wpdb->get_results( $wpdb->prepare( "DELETE 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')", $taxonomy ) );
}
}
add_action('wp_loaded', 'delete_all');
The taxonomy part I found here: http://wpsmith.net/2014/plugin-uninstall-delete-terms-taxonomies-wordpress-database/
I looked at wp_delete_term
, but I coulnd’t get it to work.