_woocommerce_term_recount

This commit is contained in:
Mike Jolley 2013-10-29 11:29:17 +00:00
parent dcf54c23bd
commit c3232d613d
2 changed files with 3 additions and 5 deletions

View File

@ -109,7 +109,7 @@ class WC_Admin_Status {
$product_tags = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
_woocommerce_term_recount( $product_cats, get_taxonomy( 'product_tag' ), false, false );
_woocommerce_term_recount( $product_tags, get_taxonomy( 'product_tag' ), false, false );
echo '<div class="updated"><p>' . __( 'Terms successfully recounted', 'woocommerce' ) . '</p></div>';
break;

View File

@ -391,11 +391,9 @@ function _woocommerce_term_recount( $terms, $taxonomy, $callback = true, $terms_
$terms = array_filter( (array) $terms );
// Ancestors need counting
if ( $terms ) {
if ( is_taxonomy_hierarchical( $taxonomy->name ) && $terms ) {
foreach ( $terms as $term_id ) {
if ( is_taxonomy_hierarchical( $taxonomy->name ) ) {
$terms = array_merge( $terms, get_ancestors( $term_id, $taxonomy->name ) );
}
$terms = array_merge( $terms, get_ancestors( $term_id, $taxonomy->name ) );
}
}