From 58a2ae494dbafcee5863e9403b76de658bffebfa Mon Sep 17 00:00:00 2001 From: Gerhard Potgieter Date: Mon, 10 Sep 2018 15:30:17 +0200 Subject: [PATCH 1/3] Review counts --- includes/class-wc-tracker.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/includes/class-wc-tracker.php b/includes/class-wc-tracker.php index bd34004ff98..edb0cab901c 100644 --- a/includes/class-wc-tracker.php +++ b/includes/class-wc-tracker.php @@ -116,6 +116,7 @@ class WC_Tracker { $data['users'] = self::get_user_counts(); $data['products'] = self::get_product_counts(); $data['orders'] = self::get_orders(); + $data['reviews'] = self::get_review_counts(); // Payment gateway info. $data['gateways'] = self::get_active_payment_gateways(); @@ -321,6 +322,32 @@ class WC_Tracker { return array_merge( $order_dates, $order_counts, $order_totals ); } + /** + * Get review counts for different statuses. + * + * @return array + */ + private static function get_review_counts() { + global $wpdb; + $review_count = array(); + $counts = $wpdb->get_results( " + SELECT comment_approved, COUNT(*) AS num_reviews + FROM {$wpdb->comments} + WHERE comment_type = 'review' + GROUP BY comment_approved + ", ARRAY_A ); + if ( $counts ) { + foreach ( $counts as $count ) { + if ( 1 === $count['comment_approved'] ) { + $review_count['approved'] = $count['num_reviews']; + } else { + $review_count['pending'] = $count['num_reviews']; + } + } + } + return $review_count; + } + /** * Get a list of all active payment gateways. * From 1f2b028b0be62e13f68a6607a868287c1f308223 Mon Sep 17 00:00:00 2001 From: Gerhard Potgieter Date: Mon, 10 Sep 2018 15:35:44 +0200 Subject: [PATCH 2/3] Category counts --- includes/class-wc-tracker.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/class-wc-tracker.php b/includes/class-wc-tracker.php index edb0cab901c..464e3b4fbc4 100644 --- a/includes/class-wc-tracker.php +++ b/includes/class-wc-tracker.php @@ -117,6 +117,7 @@ class WC_Tracker { $data['products'] = self::get_product_counts(); $data['orders'] = self::get_orders(); $data['reviews'] = self::get_review_counts(); + $data['categories'] = self::get_category_counts(); // Payment gateway info. $data['gateways'] = self::get_active_payment_gateways(); @@ -348,6 +349,15 @@ class WC_Tracker { return $review_count; } + /** + * Get the number of product categories. + * + * @return int + */ + private static function get_category_counts() { + return wp_count_terms( 'product_cat' ); + } + /** * Get a list of all active payment gateways. * From c572327ce92e1fc14b62262352c4cac23f3847ce Mon Sep 17 00:00:00 2001 From: Gerhard Potgieter Date: Mon, 10 Sep 2018 15:47:46 +0200 Subject: [PATCH 3/3] Check if helper is connected to woocommerce.com --- includes/class-wc-tracker.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/class-wc-tracker.php b/includes/class-wc-tracker.php index 464e3b4fbc4..ac7b2f26ea6 100644 --- a/includes/class-wc-tracker.php +++ b/includes/class-wc-tracker.php @@ -111,6 +111,7 @@ class WC_Tracker { $data['jetpack_is_staging'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() ) ? 'yes' : 'no'; $data['connect_installed'] = class_exists( 'WC_Connect_Loader' ) ? 'yes' : 'no'; $data['connect_active'] = ( class_exists( 'WC_Connect_Loader' ) && wp_next_scheduled( 'wc_connect_fetch_service_schemas' ) ) ? 'yes' : 'no'; + $data['helper_connected'] = self::get_helper_connected(); // Store count info. $data['users'] = self::get_user_counts(); @@ -260,6 +261,21 @@ class WC_Tracker { ); } + /** + * Check to see if the helper is connected to woocommerce.com + * + * @return string + */ + private static function get_helper_connected() { + if ( class_exists( 'WC_Helper_Options' ) && is_callable( 'WC_Helper_Options::get' ) ) { + $authenticated = WC_Helper_Options::get( 'auth' ); + } else { + $authenticated = ''; + } + return ( ! empty( $authenticated ) ) ? 'yes' : 'no'; + } + + /** * Get user totals based on user role. *