Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: deleted_term_relationships

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
1666
1667      if ( !is_array($taxonomies) )
1668           $taxonomies = array($taxonomies);
1669
1670      foreach ( (array) $taxonomies as $taxonomy ) {
1671           $tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
1672           $in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
1673           do_action( 'delete_term_relationships', $object_id, $tt_ids );
1674           $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
1675           do_action( 'deleted_term_relationships', $object_id, $tt_ids );
1676           wp_update_term_count($tt_ids, $taxonomy);
1677      }
1678 }
1679
1680 /**
1681  * Removes a term from the database.
1682  *
1683  * If the term is a parent of other terms, then the children will be updated to
1684  * that term's parent.
 
Line Code
2146      if ( $new_tt_ids )
2147           wp_update_term_count( $new_tt_ids, $taxonomy );
2148
2149      if ( ! $append ) {
2150           $delete_terms = array_diff($old_tt_ids, $tt_ids);
2151           if ( $delete_terms ) {
2152                $in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
2153                do_action( 'delete_term_relationships', $object_id, $delete_terms );
2154                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );
2155                do_action( 'deleted_term_relationships', $object_id, $delete_terms );
2156                wp_update_term_count($delete_terms, $taxonomy);
2157           }
2158      }
2159
2160      $t = get_taxonomy($taxonomy);
2161      if ( ! $append && isset($t->sort) && $t->sort ) {
2162           $values = array();
2163           $term_order = 0;
2164           $final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));