WordPress.org

Make WordPress Core

Ticket #17646: 17646.diff

File 17646.diff, 3.1 KB (added by dd32, 3 years ago)
  • wp-includes/taxonomy.php

     
    354354        unset( $args['capabilities'] ); 
    355355 
    356356        $args['name'] = $taxonomy; 
    357         $args['object_type'] =  array_unique( (array)$object_type ); 
     357        $args['object_type'] =  array_unique( (array) $object_type ); 
    358358 
    359359        $args['labels'] = get_taxonomy_labels( (object) $args ); 
    360360        $args['label'] = $args['labels']->name; 
     
    15021502 */ 
    15031503function sanitize_term($term, $taxonomy, $context = 'display') { 
    15041504 
    1505         if ( 'raw' == $context ) 
    1506                 return $term; 
     1505        //if ( 'raw' == $context ) //sanitize_term_field returns when raw after int'ing appropriate fields. 
     1506        //      return $term; 
    15071507 
    1508         $fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group'); 
     1508        $fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id'); 
    15091509 
    15101510        $do_object = false; 
    15111511        if ( is_object($term) ) 
     
    15581558 * @return mixed sanitized field 
    15591559 */ 
    15601560function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { 
    1561         if ( 'parent' == $field  || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) { 
     1561        if ( 'parent' == $field  || 'term_id' == $field || 'count' == $field || 'term_group' == $field || 'term_taxonomy_id' == $field ) { 
    15621562                $value = (int) $value; 
    15631563                if ( $value < 0 ) 
    15641564                        $value = 0; 
     
    18861886        $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"; 
    18871887 
    18881888        if ( 'all' == $fields || 'all_with_object_id' == $fields ) { 
    1889                 $terms = array_merge($terms, $wpdb->get_results($query)); 
     1889                $_terms = $wpdb->get_results($query); 
     1890                foreach ( $_terms as &$term ) 
     1891                        $term = sanitize_term($term, $taxonoy, 'raw'); 
     1892                $terms = array_merge($terms, $_terms); 
    18901893                update_term_cache($terms); 
    18911894        } else if ( 'ids' == $fields || 'names' == $fields ) { 
    1892                 $terms = array_merge($terms, $wpdb->get_col($query)); 
     1895                $_terms = $wpdb->get_col($query); 
     1896                $_field = ('ids' == $fields) ? 'term_id' : 'name'; 
     1897                foreach ( $_terms as &$term ) 
     1898                        $term = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw'); 
     1899                $terms = array_merge($terms, $_terms); 
    18931900        } else if ( 'tt_ids' == $fields ) { 
    18941901                $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"); 
     1902                foreach ( $terms as &$tt_id ) 
     1903                        $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. 
    18951904        } 
    18961905 
    18971906        if ( ! $terms ) 
     
    29012910                } 
    29022911                $termlink = home_url( user_trailingslashit($termlink, 'category') ); 
    29032912        } 
     2913 
    29042914        // Back Compat filters. 
    29052915        if ( 'post_tag' == $taxonomy ) 
    29062916                $termlink = apply_filters( 'tag_link', $termlink, $term->term_id );