Make WordPress Core

Ticket #18828: wp_get_object_terms.diff

File wp_get_object_terms.diff, 2.1 KB (added by postpostmodern, 13 years ago)

function wp_get_object_terms() fixing $taxonomy for filter

  • wp-includes/taxonomy.php

     
    18851885        if ( !empty($orderby) )
    18861886                $orderby = "ORDER BY $orderby";
    18871887
    1888         $taxonomies = "'" . implode("', '", $taxonomies) . "'";
     1888        $_taxonomies = "'" . implode("', '", $taxonomies) . "'";
    18891889        $object_ids = implode(', ', $object_ids);
    18901890
    18911891        $select_this = '';
     
    19001900        else if ( 'all_with_object_id' == $fields )
    19011901                $select_this = 't.*, tt.*, tr.object_id';
    19021902
    1903         $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";
     1903        $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($_taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";
    19041904
    19051905        if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
    19061906                $terms = array_merge($terms, $wpdb->get_results($query));
     
    19081908        } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) {
    19091909                $terms = array_merge($terms, $wpdb->get_col($query));
    19101910        } else if ( 'tt_ids' == $fields ) {
    1911                 $terms = $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) $orderby $order");
     1911                $terms = $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) $orderby $order");
    19121912        }
    19131913
    19141914        if ( ! $terms )
    19151915                $terms = array();
    1916 
     1916       
    19171917        return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
    19181918}
    19191919