WordPress.org

Make WordPress Core

Ticket #4500: terms_update.diff

File terms_update.diff, 1015 bytes (added by cavemonkey50, 7 years ago)
  • wp-includes/taxonomy.php

     
    791791        $terms = array_map('intval', $terms); 
    792792 
    793793        $taxonomy = get_taxonomy($taxonomy); 
    794         if ( isset($taxonomy->update_count_callback) ) 
     794        if ( ( isset($taxonomy->update_count_callback) ) && ( '' != $taxonomy->update_count_callback ) ) 
    795795                return call_user_func($taxonomy->update_count_callback, $terms); 
    796796 
    797797        // Default count updater 
    798         $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'"); 
    799         $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'"); 
     798        foreach ($terms as $term) { 
     799                $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'"); 
     800                $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'"); 
     801        } 
    800802 
    801803        return true; 
    802804}