Ticket #17646: 17646.3.diff
File 17646.3.diff, 2.7 KB (added by , 11 years ago) |
---|
-
wp-includes/taxonomy.php
1580 1580 */ 1581 1581 function sanitize_term($term, $taxonomy, $context = 'display') { 1582 1582 1583 if ( 'raw' == $context ) 1584 return $term; 1583 $fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' ); 1585 1584 1586 $fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group');1587 1588 1585 $do_object = false; 1589 1586 if ( is_object($term) ) 1590 1587 $do_object = true; … … 1636 1633 * @return mixed sanitized field 1637 1634 */ 1638 1635 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { 1639 if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) { 1640 $value = (int) $value; 1641 if ( $value < 0 ) 1642 $value = 0; 1643 } 1636 $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); 1637 if ( in_array( $field, $int_fields ) ) 1638 $value = absint( $value ); 1644 1639 1645 1640 if ( 'raw' == $context ) 1646 1641 return $value; … … 1971 1966 $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"; 1972 1967 1973 1968 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 1974 $terms = array_merge($terms, $wpdb->get_results($query)); 1975 update_term_cache($terms); 1969 $_terms = $wpdb->get_results( $query ); 1970 foreach ( $_terms as &$term ) 1971 $term = sanitize_term( $term, $taxonomy, 'raw' ); 1972 $terms = array_merge( $terms, $_terms ); 1973 update_term_cache( $terms ); 1976 1974 } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { 1977 $terms = array_merge($terms, $wpdb->get_col($query)); 1975 $_terms = $wpdb->get_col( $query ); 1976 $_field = ( 'ids' == $fields ) ? 'term_id' : 'name'; 1977 foreach ( $_terms as &$term ) 1978 $term = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw' ); 1979 $terms = array_merge( $terms, $_terms ); 1978 1980 } else if ( 'tt_ids' == $fields ) { 1979 1981 $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"); 1982 foreach ( $terms as &$tt_id ) 1983 $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. 1980 1984 } 1981 1985 1982 1986 if ( ! $terms )