Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: set_object_terms

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
1512           $term_order = 0;
1513           $final_tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
1514           foreach ( $tt_ids as $tt_id )
1515                if ( in_array($tt_id, $final_tt_ids) )
1516                     $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
1517           if ( $values )
1518                $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
1519      }
1520
1521      do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
1522      return $tt_ids;
1523 }
1524
1525 /**
1526  * Will make slug unique, if it isn't already.
1527  *
1528  * The $slug has to be unique global to every taxonomy, meaning that one
1529  * taxonomy term can't have a matching slug with another taxonomy term. Each
1530  * slug has to be globally unique for every taxonomy.