If checking for term within taxonomy, just do the taxonomy specific query. Saves one query.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-10-13 19:04:39 +00:00
parent befa8f0f11
commit 24af93e9c0
1 changed files with 3 additions and 6 deletions

View File

@ -642,13 +642,10 @@ function is_term($term, $taxonomy = '') {
$where = $wpdb->prepare( "t.slug = %s", $term );
}
$term_id = $wpdb->get_var("SELECT term_id FROM $wpdb->terms as t WHERE $where");
if ( !empty($taxonomy) )
return $wpdb->get_row("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = '$taxonomy'", ARRAY_A);
if ( empty($taxonomy) || empty($term_id) )
return $term_id;
$taxonomy = $wpdb->escape( $taxonomy );
return $wpdb->get_row("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = '$taxonomy'", ARRAY_A);
return $wpdb->get_var("SELECT term_id FROM $wpdb->terms as t WHERE $where");
}
/**