Changeset 26010 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 11/05/2013 01:18:02 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r25948 r26010 1659 1659 function sanitize_term($term, $taxonomy, $context = 'display') { 1660 1660 1661 if ( 'raw' == $context ) 1662 return $term; 1663 1664 $fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group'); 1665 1666 $do_object = false; 1667 if ( is_object($term) ) 1668 $do_object = true; 1661 $fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' ); 1662 1663 $do_object = is_object( $term ); 1669 1664 1670 1665 $term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0); … … 1715 1710 */ 1716 1711 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { 1717 if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) { 1718 $value = (int) $value; 1719 if ( $value < 0 ) 1720 $value = 0; 1721 } 1712 $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); 1713 if ( in_array( $field, $int_fields ) ) 1714 $value = absint( $value ); 1722 1715 1723 1716 if ( 'raw' == $context ) … … 2050 2043 2051 2044 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 2052 $terms = array_merge($terms, $wpdb->get_results($query)); 2053 update_term_cache($terms); 2045 $_terms = $wpdb->get_results( $query ); 2046 foreach ( $_terms as &$term ) 2047 $term = sanitize_term( $term, $taxonomy, 'raw' ); 2048 $terms = array_merge( $terms, $_terms ); 2049 update_term_cache( $terms ); 2054 2050 } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { 2055 $terms = array_merge($terms, $wpdb->get_col($query)); 2051 $_terms = $wpdb->get_col( $query ); 2052 $_field = ( 'ids' == $fields ) ? 'term_id' : 'name'; 2053 foreach ( $_terms as &$term ) 2054 $term = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw' ); 2055 $terms = array_merge( $terms, $_terms ); 2056 2056 } else if ( 'tt_ids' == $fields ) { 2057 2057 $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"); 2058 foreach ( $terms as &$tt_id ) 2059 $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. 2058 2060 } 2059 2061
Note: See TracChangeset
for help on using the changeset viewer.