wp_update_term_count fixes from cavemonkey50. fixes #4500

git-svn-id: https://develop.svn.wordpress.org/trunk@5866 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-08-14 02:54:02 +00:00
parent ebf9ab90b6
commit 9d8324b07b
1 changed files with 5 additions and 3 deletions

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;
}