From bbcffa4c56c1651e0896709eba8eead606eb9285 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sun, 27 May 2007 06:29:52 +0000 Subject: [PATCH] Delete term if no taxonomies use it. see #4189 git-svn-id: https://develop.svn.wordpress.org/trunk@5559 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 50ed17dd89..9eb9c43cd2 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -165,6 +165,10 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) { $wpdb->query("DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = '$tt_id'"); + // Delete the term if no taxonomies use it. + if ( !$wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = '$term'") ) + $wpdb->query("DELETE FROM $wpdb->terms WHERE term_id = '$term'"); + clean_term_cache($term, $taxonomy); do_action("delete_$taxonomy", $term, $tt_id);