From 49953705f1a9b36ef7c740017facf16edc5f516d Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 27 May 2007 06:29:52 +0000 Subject: [PATCH] Delete term if no taxonomies use it. see #4189 git-svn-id: http://svn.automattic.com/wordpress/trunk@5559 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 50ed17dd8..9eb9c43cd 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);