Delete term if no taxonomies use it. see #4189

git-svn-id: http://svn.automattic.com/wordpress/trunk@5559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-05-27 06:29:52 +00:00
parent 128bbfa161
commit 49953705f1
1 changed files with 4 additions and 0 deletions

View File

@ -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);