web/wp-includes/taxonomy.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
   299  * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
   299  * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
   300  * exist then WP_Error will be returned.
   300  * exist then WP_Error will be returned.
   301  */
   301  */
   302 function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
   302 function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
   303 	global $wpdb;
   303 	global $wpdb;
       
   304 	$null = null;
   304 
   305 
   305 	if ( empty($term) ) {
   306 	if ( empty($term) ) {
   306 		$error = new WP_Error('invalid_term', __('Empty Term'));
   307 		$error = new WP_Error('invalid_term', __('Empty Term'));
   307 		return $error;
   308 		return $error;
   308 	}
   309 	}
   319 		if ( is_object($term) )
   320 		if ( is_object($term) )
   320 			$term = $term->term_id;
   321 			$term = $term->term_id;
   321 		$term = (int) $term;
   322 		$term = (int) $term;
   322 		if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
   323 		if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
   323 			$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
   324 			$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
       
   325 			if ( ! $_term )
       
   326 				return $null;
   324 			wp_cache_add($term, $_term, $taxonomy);
   327 			wp_cache_add($term, $_term, $taxonomy);
   325 		}
   328 		}
   326 	}
   329 	}
   327 
   330 
   328 	$_term = apply_filters('get_term', $_term, $taxonomy);
   331 	$_term = apply_filters('get_term', $_term, $taxonomy);
  1076 		$taxonomies = array($taxonomies);
  1079 		$taxonomies = array($taxonomies);
  1077 
  1080 
  1078 	foreach ( (array) $taxonomies as $taxonomy ) {
  1081 	foreach ( (array) $taxonomies as $taxonomy ) {
  1079 		$tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
  1082 		$tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
  1080 		$in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
  1083 		$in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
       
  1084 		do_action( 'delete_term_relationships', $object_id, $tt_ids );
  1081 		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
  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 );
  1082 		wp_update_term_count($tt_ids, $taxonomy);
  1087 		wp_update_term_count($tt_ids, $taxonomy);
  1083 	}
  1088 	}
  1084 }
  1089 }
  1085 
  1090 
  1086 /**
  1091 /**
  1135 		$term_obj = get_term($term, $taxonomy);
  1140 		$term_obj = get_term($term, $taxonomy);
  1136 		if ( is_wp_error( $term_obj ) )
  1141 		if ( is_wp_error( $term_obj ) )
  1137 			return $term_obj;
  1142 			return $term_obj;
  1138 		$parent = $term_obj->parent;
  1143 		$parent = $term_obj->parent;
  1139 
  1144 
       
  1145 		$edit_tt_ids = $wpdb->get_col( "SELECT `term_taxonomy_id` FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
       
  1146 		do_action( 'edit_term_taxonomies', $edit_tt_ids );
  1140 		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
  1147 		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
       
  1148 		do_action( 'edited_term_taxonomies', $edit_tt_ids );
  1141 	}
  1149 	}
  1142 
  1150 
  1143 	$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
  1151 	$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
  1144 
  1152 
  1145 	foreach ( (array) $objects as $object ) {
  1153 	foreach ( (array) $objects as $object ) {
  1153 		}
  1161 		}
  1154 		$terms = array_map('intval', $terms);
  1162 		$terms = array_map('intval', $terms);
  1155 		wp_set_object_terms($object, $terms, $taxonomy);
  1163 		wp_set_object_terms($object, $terms, $taxonomy);
  1156 	}
  1164 	}
  1157 
  1165 
       
  1166 	do_action( 'delete_term_taxonomy', $tt_id );
  1158 	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id ) );
  1167 	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id ) );
       
  1168 	do_action( 'deleted_term_taxonomy', $tt_id );
  1159 
  1169 
  1160 	// Delete the term if no taxonomies use it.
  1170 	// Delete the term if no taxonomies use it.
  1161 	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
  1171 	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
  1162 		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );
  1172 		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );
  1163 
  1173 
  1375 			// The alias we want is already in a group, so let's use that one.
  1385 			// The alias we want is already in a group, so let's use that one.
  1376 			$term_group = $alias->term_group;
  1386 			$term_group = $alias->term_group;
  1377 		} else {
  1387 		} else {
  1378 			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
  1388 			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
  1379 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
  1389 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
       
  1390 			do_action( 'edit_terms', $alias->term_id );
  1380 			$wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) );
  1391 			$wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) );
       
  1392 			do_action( 'edited_terms', $alias->term_id );
  1381 		}
  1393 		}
  1382 	}
  1394 	}
  1383 
  1395 
  1384 	if ( ! $term_id = is_term($slug) ) {
  1396 	if ( ! $term_id = is_term($slug) ) {
  1385 		if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
  1397 		if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
  1394 		$term_id = (int) $wpdb->insert_id;
  1406 		$term_id = (int) $wpdb->insert_id;
  1395 	}
  1407 	}
  1396 
  1408 
  1397 	if ( empty($slug) ) {
  1409 	if ( empty($slug) ) {
  1398 		$slug = sanitize_title($slug, $term_id);
  1410 		$slug = sanitize_title($slug, $term_id);
       
  1411 		do_action( 'edit_terms', $term_id );
  1399 		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
  1412 		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
       
  1413 		do_action( 'edited_terms', $term_id );
  1400 	}
  1414 	}
  1401 
  1415 
  1402 	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) );
  1416 	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) );
  1403 
  1417 
  1404 	if ( !empty($tt_id) )
  1418 	if ( !empty($tt_id) )
  1405 		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  1419 		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  1406 
  1420 
  1407 	$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) );
  1421 	$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) );
  1408 	$tt_id = (int) $wpdb->insert_id;
  1422 	$tt_id = (int) $wpdb->insert_id;
  1409 
  1423 
  1410 	do_action("create_term", $term_id, $tt_id);
  1424 	do_action("create_term", $term_id, $tt_id, $taxonomy);
  1411 	do_action("create_$taxonomy", $term_id, $tt_id);
  1425 	do_action("create_$taxonomy", $term_id, $tt_id);
  1412 
  1426 
  1413 	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
  1427 	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
  1414 
  1428 
  1415 	clean_term_cache($term_id, $taxonomy);
  1429 	clean_term_cache($term_id, $taxonomy);
  1416 
  1430 
  1417 	do_action("created_term", $term_id, $tt_id);
  1431 	do_action("created_term", $term_id, $tt_id, $taxonomy);
  1418 	do_action("created_$taxonomy", $term_id, $tt_id);
  1432 	do_action("created_$taxonomy", $term_id, $tt_id);
  1419 
  1433 
  1420 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  1434 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  1421 }
  1435 }
  1422 
  1436 
  1472 		$tt_id = $term_info['term_taxonomy_id'];
  1486 		$tt_id = $term_info['term_taxonomy_id'];
  1473 		$tt_ids[] = $tt_id;
  1487 		$tt_ids[] = $tt_id;
  1474 
  1488 
  1475 		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 ) ) )
  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 ) ) )
  1476 			continue;
  1490 			continue;
       
  1491 		do_action( 'add_term_relationship', $object_id, $tt_id );
  1477 		$wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_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 );
  1478 	}
  1494 	}
  1479 
  1495 
  1480 	wp_update_term_count($tt_ids, $taxonomy);
  1496 	wp_update_term_count($tt_ids, $taxonomy);
  1481 
  1497 
  1482 	if ( ! $append ) {
  1498 	if ( ! $append ) {
  1483 		$delete_terms = array_diff($old_tt_ids, $tt_ids);
  1499 		$delete_terms = array_diff($old_tt_ids, $tt_ids);
  1484 		if ( $delete_terms ) {
  1500 		if ( $delete_terms ) {
  1485 			$in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
  1501 			$in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
       
  1502 			do_action( 'delete_term_relationships', $object_id, $delete_terms );
  1486 			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );
  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 );
  1487 			wp_update_term_count($delete_terms, $taxonomy);
  1505 			wp_update_term_count($delete_terms, $taxonomy);
  1488 		}
  1506 		}
  1489 	}
  1507 	}
  1490 
  1508 
  1491 	$t = get_taxonomy($taxonomy);
  1509 	$t = get_taxonomy($taxonomy);
  1498 				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
  1516 				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
  1499 		if ( $values )
  1517 		if ( $values )
  1500 			$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)");
  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)");
  1501 	}
  1519 	}
  1502 
  1520 
  1503 	do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append);
  1521 	do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
  1504 	return $tt_ids;
  1522 	return $tt_ids;
  1505 }
  1523 }
  1506 
  1524 
  1507 /**
  1525 /**
  1508  * Will make slug unique, if it isn't already.
  1526  * Will make slug unique, if it isn't already.
  1644 			// The alias we want is already in a group, so let's use that one.
  1662 			// The alias we want is already in a group, so let's use that one.
  1645 			$term_group = $alias->term_group;
  1663 			$term_group = $alias->term_group;
  1646 		} else {
  1664 		} else {
  1647 			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
  1665 			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
  1648 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
  1666 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
       
  1667 			do_action( 'edit_terms', $alias->term_id );
  1649 			$wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );
  1668 			$wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );
       
  1669 			do_action( 'edited_terms', $alias->term_id );
  1650 		}
  1670 		}
  1651 	}
  1671 	}
  1652 
  1672 
  1653 	// Check for duplicate slug
  1673 	// Check for duplicate slug
  1654 	$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
  1674 	$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
  1658 		if ( $empty_slug || ( $parent != $term->parent) )
  1678 		if ( $empty_slug || ( $parent != $term->parent) )
  1659 			$slug = wp_unique_term_slug($slug, (object) $args);
  1679 			$slug = wp_unique_term_slug($slug, (object) $args);
  1660 		else
  1680 		else
  1661 			return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug));
  1681 			return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug));
  1662 	}
  1682 	}
  1663 
  1683 	do_action( 'edit_terms', $term_id );
  1664 	$wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
  1684 	$wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
  1665 
       
  1666 	if ( empty($slug) ) {
  1685 	if ( empty($slug) ) {
  1667 		$slug = sanitize_title($name, $term_id);
  1686 		$slug = sanitize_title($name, $term_id);
  1668 		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
  1687 		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
  1669 	}
  1688 	}
       
  1689 	do_action( 'edited_terms', $term_id );
  1670 
  1690 
  1671 	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );
  1691 	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );
  1672 
  1692 	do_action( 'edit_term_taxonomy', $tt_id );
  1673 	$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
  1693 	$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
  1674 
  1694 	do_action( 'edited_term_taxonomy', $tt_id );
  1675 	do_action("edit_term", $term_id, $tt_id);
  1695 
       
  1696 	do_action("edit_term", $term_id, $tt_id, $taxonomy);
  1676 	do_action("edit_$taxonomy", $term_id, $tt_id);
  1697 	do_action("edit_$taxonomy", $term_id, $tt_id);
  1677 
  1698 
  1678 	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
  1699 	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
  1679 
  1700 
  1680 	clean_term_cache($term_id, $taxonomy);
  1701 	clean_term_cache($term_id, $taxonomy);
  1681 
  1702 
  1682 	do_action("edited_term", $term_id, $tt_id);
  1703 	do_action("edited_term", $term_id, $tt_id, $taxonomy);
  1683 	do_action("edited_$taxonomy", $term_id, $tt_id);
  1704 	do_action("edited_$taxonomy", $term_id, $tt_id);
  1684 
  1705 
  1685 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  1706 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  1686 }
  1707 }
  1687 
  1708 
  1769 		call_user_func($taxonomy->update_count_callback, $terms);
  1790 		call_user_func($taxonomy->update_count_callback, $terms);
  1770 	} else {
  1791 	} else {
  1771 		// Default count updater
  1792 		// Default count updater
  1772 		foreach ( (array) $terms as $term) {
  1793 		foreach ( (array) $terms as $term) {
  1773 			$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
  1794 			$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
       
  1795 			do_action( 'edit_term_taxonomy', $term );
  1774 			$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
  1796 			$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
       
  1797 			do_action( 'edited_term_taxonomy', $term );
  1775 		}
  1798 		}
  1776 
  1799 
  1777 	}
  1800 	}
  1778 
  1801 
  1779 	clean_term_cache($terms);
  1802 	clean_term_cache($terms);
  2151 function _update_post_term_count( $terms ) {
  2174 function _update_post_term_count( $terms ) {
  2152 	global $wpdb;
  2175 	global $wpdb;
  2153 
  2176 
  2154 	foreach ( (array) $terms as $term ) {
  2177 	foreach ( (array) $terms as $term ) {
  2155 		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) );
  2178 		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) );
       
  2179 		do_action( 'edit_term_taxonomy', $term );
  2156 		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
  2180 		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
       
  2181 		do_action( 'edited_term_taxonomy', $term );
  2157 	}
  2182 	}
  2158 }
  2183 }
  2159 
  2184 
  2160 
  2185 
  2161 /**
  2186 /**
  2189 	$termlink = $wp_rewrite->get_extra_permastruct($taxonomy);
  2214 	$termlink = $wp_rewrite->get_extra_permastruct($taxonomy);
  2190 
  2215 
  2191 	$slug = $term->slug;
  2216 	$slug = $term->slug;
  2192 
  2217 
  2193 	if ( empty($termlink) ) {
  2218 	if ( empty($termlink) ) {
  2194 		$file = get_option('home') . '/';
  2219 		$file = trailingslashit( get_option('home') );
  2195 		$t = get_taxonomy($taxonomy);
  2220 		$t = get_taxonomy($taxonomy);
  2196 		if ( $t->query_var )
  2221 		if ( $t->query_var )
  2197 			$termlink = "$file?$t->query_var=$slug";
  2222 			$termlink = "$file?$t->query_var=$slug";
  2198 		else
  2223 		else
  2199 			$termlink = "$file?taxonomy=$taxonomy&term=$slug";
  2224 			$termlink = "$file?taxonomy=$taxonomy&term=$slug";