From 2fe73132c69a28bf4682dc5be8916b7bfaf02130 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 13 Oct 2007 19:04:39 +0000 Subject: [PATCH] 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 --- wp-includes/taxonomy.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 8a5bceb853..521ba96cd9 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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"); } /**