[WC Tracker]: Track brands count (#52056)

* [WC Tracker]: Track brands count

* Add changefile(s) from automation for the following project(s): woocommerce

* Handle case where the product_brand taxonomy doesn't exist.

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Jason Kytros 2024-10-23 09:39:49 +03:00 committed by GitHub
parent dc8fdcfb9a
commit 24403c244e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Added tracking for number of brands.

View File

@ -179,6 +179,7 @@ class WC_Tracker {
$data['orders'] = self::get_orders(); $data['orders'] = self::get_orders();
$data['reviews'] = self::get_review_counts(); $data['reviews'] = self::get_review_counts();
$data['categories'] = self::get_category_counts(); $data['categories'] = self::get_category_counts();
$data['brands'] = self::get_brands_counts();
// Payment gateway info. // Payment gateway info.
$data['gateways'] = self::get_active_payment_gateways(); $data['gateways'] = self::get_active_payment_gateways();
@ -882,6 +883,18 @@ class WC_Tracker {
return wp_count_terms( 'product_cat' ); return wp_count_terms( 'product_cat' );
} }
/**
* Get the number of product brands.
*
* @return int
*/
private static function get_brands_counts() {
if ( ! taxonomy_exists( 'product_brand' ) ) {
return 0;
}
return wp_count_terms( 'product_brand' );
}
/** /**
* Get a list of all active payment gateways. * Get a list of all active payment gateways.
* *