Delete term if no taxonomies use it. see #4189

git-svn-id: https://develop.svn.wordpress.org/trunk@5559 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-05-27 06:29:52 +00:00
parent 6485c0e03f
commit bbcffa4c56
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);