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

git-svn-id: https://develop.svn.wordpress.org/trunk@6246 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-10-13 19:04:39 +00:00
parent cf584c357f
commit 2fe73132c6
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");
}
/**