Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: delete_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
1075
1076      $object_id = (int) $object_id;
1077
1078      if ( !is_array($taxonomies) )
1079           $taxonomies = array($taxonomies);
1080
1081      foreach ( (array) $taxonomies as $taxonomy ) {
1082           $tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
1083           $in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
1084           do_action( 'delete_term_relationships', $object_id, $tt_ids );
1085           $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
1086           do_action( 'deleted_term_relationships', $object_id, $tt_ids );
1087           wp_update_term_count($tt_ids, $taxonomy);
1088      }
1089 }
1090
1091 /**
1092  * Removes a term from the database.
1093  *
 
Line Code
1493           do_action( 'added_term_relationship', $object_id, $tt_id );
1494      }
1495
1496      wp_update_term_count($tt_ids, $taxonomy);
1497
1498      if ( ! $append ) {
1499           $delete_terms = array_diff($old_tt_ids, $tt_ids);
1500           if ( $delete_terms ) {
1501                $in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
1502                do_action( 'delete_term_relationships', $object_id, $delete_terms );
1503                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );
1504                do_action( 'deleted_term_relationships', $object_id, $delete_terms );
1505                wp_update_term_count($delete_terms, $taxonomy);
1506           }
1507      }
1508
1509      $t = get_taxonomy($taxonomy);
1510      if ( ! $append && isset($t->sort) && $t->sort ) {
1511           $values = array();