WordPress.org

Make WordPress Core

Ticket #6593: is_term.diff

File is_term.diff, 2.4 KB (added by ryan, 10 years ago)
  • wp-includes/taxonomy.php

     
    766766                        return 0;
    767767                $where = 't.term_id = %d';
    768768        } else {
    769                 if ( '' === $term = sanitize_title($term) )
     769                if ( '' === $slug = sanitize_title($term) )
    770770                        return 0;
    771771                $where = 't.slug = %s';
     772                $else_where = 't.name = %s';
    772773        }
    773774
    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", $term, $taxonomy), ARRAY_A);
     775        if ( !empty($taxonomy) ) {
     776                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) )
     777                        return $result;
     778                else
     779                        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);
     780        }
    776781
    777         return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $term) );
     782        if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $slug) ) )
     783                return $result;
     784        else
     785                return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $term) );
    778786}
    779787
    780788/**
  • wp-includes/version.php

     
    1515 *
    1616 * @global int $wp_db_version
    1717 */
    18 $wp_db_version = 8202;
     18$wp_db_version = 8370;
    1919
    2020?>
  • wp-admin/includes/schema.php

     
    1919 slug varchar(200) NOT NULL default '',
    2020 term_group bigint(10) NOT NULL default 0,
    2121 PRIMARY KEY  (term_id),
    22  UNIQUE KEY slug (slug)
     22 UNIQUE KEY slug (slug),
     23 KEY name (name)
    2324) $charset_collate;
    2425CREATE TABLE $wpdb->term_taxonomy (
    2526 term_taxonomy_id bigint(20) NOT NULL auto_increment,