Ticket #18828: wp_get_object_terms.diff
File wp_get_object_terms.diff, 2.1 KB (added by , 13 years ago) |
---|
-
wp-includes/taxonomy.php
1885 1885 if ( !empty($orderby) ) 1886 1886 $orderby = "ORDER BY $orderby"; 1887 1887 1888 $ taxonomies = "'" . implode("', '", $taxonomies) . "'";1888 $_taxonomies = "'" . implode("', '", $taxonomies) . "'"; 1889 1889 $object_ids = implode(', ', $object_ids); 1890 1890 1891 1891 $select_this = ''; … … 1900 1900 else if ( 'all_with_object_id' == $fields ) 1901 1901 $select_this = 't.*, tt.*, tr.object_id'; 1902 1902 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"; 1904 1904 1905 1905 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 1906 1906 $terms = array_merge($terms, $wpdb->get_results($query)); … … 1908 1908 } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { 1909 1909 $terms = array_merge($terms, $wpdb->get_col($query)); 1910 1910 } 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"); 1912 1912 } 1913 1913 1914 1914 if ( ! $terms ) 1915 1915 $terms = array(); 1916 1916 1917 1917 return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args); 1918 1918 } 1919 1919