WordPress.org

Make WordPress Core

Changeset 5567


Ignore:
Timestamp:
05/28/07 00:51:24 (8 years ago)
Author:
ryan
Message:

Register taxonomies as object instead of arrays. Fix tt_ids query in get_post_terms().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r5563 r5567  
    11<?php 
    22 
    3 $wp_taxonomies = 
    4 array('category' => array('object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count'), 
    5 'post_tag' => array('object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count'), 
    6 'link_category' => array('object_type' => 'link', 'hierarchical' => false)); 
    7  
     3$wp_taxonomies = array(); 
     4$wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count'); 
     5$wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count'); 
     6$wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false); 
     7 
     8//error_log(var_export($wp_taxonomies, true), 0); 
    89function is_taxonomy( $taxonomy ) { 
    910    global $wp_taxonomies; 
     
    2627 
    2728    $taxonomy = get_taxonomy($taxonomy); 
    28     return $taxonomy['hierarchical']; 
     29    return $taxonomy->hierarchical; 
    2930} 
    3031 
     
    3233    global $wp_taxonomies; 
    3334 
     35    $defaults = array('hierarchical' => false, 'update_count_callback' => ''); 
     36    $args = wp_parse_args($args, $defaults); 
     37 
     38    $args['name'] = $taxonomy; 
    3439    $args['object_type'] = $object_type; 
    35     $wp_taxonomies[$taxonomy] = $args; 
     40    $wp_taxonomies[$taxonomy] = (object) $args; 
    3641} 
    3742 
     
    260265 
    261266    $taxonomy = get_taxonomy($taxonomy); 
    262     if ( isset($taxonomy['update_count_callback']) ) 
    263         return call_user_func($taxonomy['update_count_callback'], $terms); 
     267    if ( isset($taxonomy->update_count_callback) ) 
     268        return call_user_func($taxonomy->update_count_callback, $terms); 
    264269 
    265270    // Default count updater 
     
    338343        $id = $id['term_taxonomy_id']; 
    339344        $tt_ids[] = $id; 
     345 
    340346        if ( $wpdb->get_var("SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = '$object_id' AND term_taxonomy_id = '$id'") ) 
    341347            continue; 
     
    401407        $taxonomy_data = $wpdb->get_col($query); 
    402408    else if ( 'tt_ids' == $fields ) 
    403         $taxonomy_data = $wpdb->get_col("SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id IN ($object_ids) ORDER BY term_taxonomy_id $order"); 
     409        $taxonomy_data = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) ORDER BY tr.term_taxonomy_id $order"); 
    404410 
    405411    if ( ! $taxonomy_data ) 
Note: See TracChangeset for help on using the changeset viewer.