Changes from trunk/wp-includes/taxonomy.php at r8225 to branches/2.6/wp-includes/taxonomy.php at r8559
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.6/wp-includes/taxonomy.php
r8225 r8559 762 762 global $wpdb; 763 763 764 $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; 765 $tax_select = "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 "; 766 764 767 if ( is_int($term) ) { 765 768 if ( 0 == $term ) 766 769 return 0; 767 $where = $wpdb->prepare( "t.term_id = %d", $term ); 768 } else { 769 if ( '' === $term = sanitize_title($term) ) 770 return 0; 771 $where = $wpdb->prepare( "t.slug = %s", $term ); 772 } 773 774 if ( !empty($taxonomy) ) 775 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 $where AND tt.taxonomy = %s", $taxonomy), ARRAY_A); 776 777 return $wpdb->get_var("SELECT term_id FROM $wpdb->terms as t WHERE $where"); 770 $where = 't.term_id = %d'; 771 if ( !empty($taxonomy) ) 772 return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A ); 773 else 774 return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); 775 } 776 777 if ( '' === $slug = sanitize_title($term) ) 778 return 0; 779 780 $where = 't.slug = %s'; 781 $else_where = 't.name = %s'; 782 783 if ( !empty($taxonomy) ) { 784 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) ) 785 return $result; 786 787 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); 788 } 789 790 if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $slug) ) ) 791 return $result; 792 793 return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $term) ); 778 794 } 779 795 … … 1200 1216 return new WP_Error('invalid_term_id', __('Invalid term ID')); 1201 1217 1218 if ( '' == trim($term) ) 1219 return new WP_Error('empty_term_name', __('A name is required for this term')); 1220 1202 1221 $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); 1203 1222 $args = wp_parse_args($args, $defaults); … … 1469 1488 $name = stripslashes($name); 1470 1489 $description = stripslashes($description); 1490 1491 if ( '' == trim($name) ) 1492 return new WP_Error('empty_term_name', __('A name is required for this term')); 1471 1493 1472 1494 $empty_slug = false;
Note: See TracChangeset
for help on using the changeset viewer.