Ticket #17646: 17646.sw.2.diff
| File 17646.sw.2.diff, 2.6 KB (added by , 13 years ago) |
|---|
-
wp-includes/taxonomy.php
1561 1561 */ 1562 1562 function sanitize_term($term, $taxonomy, $context = 'display') { 1563 1563 1564 if ( 'raw' == $context )1565 return $term;1564 // if ( 'raw' == $context ) //sanitize_term_field returns when raw after int'ing appropriate fields. 1565 // return $term; 1566 1566 1567 $fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group');1567 $fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id' ); 1568 1568 1569 1569 $do_object = false; 1570 1570 if ( is_object($term) ) … … 1617 1617 * @return mixed sanitized field 1618 1618 */ 1619 1619 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { 1620 if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {1620 if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field || 'term_taxonomy_id' == $field ) { 1621 1621 $value = (int) $value; 1622 1622 if ( $value < 0 ) 1623 1623 $value = 0; … … 1950 1950 $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"; 1951 1951 1952 1952 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 1953 $terms = array_merge($terms, $wpdb->get_results($query)); 1953 $_terms = $wpdb->get_results($query); 1954 foreach ( $_terms as &$term ) 1955 $term = sanitize_term($term, $taxonomy, 'raw'); 1956 $terms = array_merge($terms, $_terms); 1954 1957 update_term_cache($terms); 1955 1958 } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { 1956 $terms = array_merge($terms, $wpdb->get_col($query)); 1959 $_terms = $wpdb->get_col($query); 1960 $_field = ('ids' == $fields) ? 'term_id' : 'name'; 1961 foreach ( $_terms as &$term ) 1962 $term = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw'); 1963 $terms = array_merge($terms, $_terms); 1957 1964 } else if ( 'tt_ids' == $fields ) { 1958 1965 $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"); 1966 foreach ( $terms as &$tt_id ) 1967 $tt_id = sanitize_term_field( 'term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw'); // 0 should be the term id, however is not needed when using raw context. 1959 1968 } 1960 1969 1961 1970 if ( ! $terms )