Changeset 10905 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 04/10/2009 08:58:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/taxonomy.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r10813 r10905 835 835 * @param int|string $term The term to check 836 836 * @param string $taxonomy The taxonomy name to use 837 * @param int $parent ID of parent term under which to confine the exists search. 837 838 * @return mixed Get the term id or Term Object, if exists. 838 839 */ 839 function is_term($term, $taxonomy = '' ) {840 function is_term($term, $taxonomy = '', $parent = 0) { 840 841 global $wpdb; 841 842 … … 858 859 $where = 't.slug = %s'; 859 860 $else_where = 't.name = %s'; 860 861 $where_fields = array($slug); 862 $else_where_fields = array($term); 861 863 if ( !empty($taxonomy) ) { 862 if ( $result = $wpdb->get_row( $wpdb->prepare("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 = %s", $slug, $taxonomy), ARRAY_A) ) 864 $parent = (int) $parent; 865 if ( $parent > 0 ) { 866 $where_fields[] = $parent; 867 $else_where_fields[] = $parent; 868 $where .= ' AND tt.parent = %d'; 869 $else_where .= ' AND tt.parent = %d'; 870 } 871 872 $where_fields[] = $taxonomy; 873 $else_where_fields[] = $taxonomy; 874 875 if ( $result = $wpdb->get_row( $wpdb->prepare("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 = %s", $where_fields), ARRAY_A) ) 863 876 return $result; 864 877 865 return $wpdb->get_row( $wpdb->prepare("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 $else_where AND tt.taxonomy = %s", $ term, $taxonomy), ARRAY_A);866 } 867 868 if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $ slug) ) )878 return $wpdb->get_row( $wpdb->prepare("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 $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A); 879 } 880 881 if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields) ) ) 869 882 return $result; 870 883 871 return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $ term) );884 return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) ); 872 885 } 873 886
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)