WordPress.org

Make WordPress Core

Ticket #20635: 20635.diff

File 20635.diff, 1.4 KB (added by jkudish, 17 months ago)

add term hierarchy loop detection to _pad_term_counts()

  • wp-includes/default-filters.php

     
    127127add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); 
    128128add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); 
    129129 
     130// Pad terms count hierarchy loop detection 
     131add_filter( '_pad_term_counts_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); 
     132 
    130133// Display filters 
    131134add_filter( 'the_title', 'wptexturize'   ); 
    132135add_filter( 'the_title', 'convert_chars' ); 
  • wp-includes/taxonomy.php

     
    28822882        foreach ( $term_ids as $term_id ) { 
    28832883                $child = $term_id; 
    28842884                while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) { 
     2885 
     2886                // Check $parent to see if it will cause a hierarchy loop 
     2887                $parent = apply_filters( '_pad_term_counts_term_parent', $parent, $term_id, $taxonomy ); 
     2888 
    28852889                        if ( !empty( $term_items[$term_id] ) ) 
    28862890                                foreach ( $term_items[$term_id] as $item_id => $touches ) { 
    28872891                                        $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;