wp_update_term_count fixes from cavemonkey50. fixes #4500

git-svn-id: http://svn.automattic.com/wordpress/trunk@5866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-08-14 02:54:02 +00:00
parent 7c1ce10fae
commit 638d5e6e39

View File

@ -789,12 +789,14 @@ function wp_update_term_count( $terms, $taxonomy ) {
$terms = array_map('intval', $terms);
$taxonomy = get_taxonomy($taxonomy);
if ( isset($taxonomy->update_count_callback) )
if ( !empty($taxonomy->update_count_callback) )
return call_user_func($taxonomy->update_count_callback, $terms);
// Default count updater
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'");
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'");
foreach ($terms as $term) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'");
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'");
}
return true;
}