Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: added_term_relationship

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

Line Code
1484                return $term_info;
1485           $term_ids[] = $term_info['term_id'];
1486           $tt_id = $term_info['term_taxonomy_id'];
1487           $tt_ids[] = $tt_id;
1488
1489           if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) )
1490                continue;
1491           do_action( 'add_term_relationship', $object_id, $tt_id );
1492           $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
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 );