From 45e881b2a19c1c56d3f67f6ce84b43f978bc82f6 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Sat, 25 Feb 2012 19:17:11 +0400 Subject: [PATCH] Separate dashboard right now widget --- admin/woocommerce-admin-dashboard.php | 213 ++++++++++++++++++-------- 1 file changed, 150 insertions(+), 63 deletions(-) diff --git a/admin/woocommerce-admin-dashboard.php b/admin/woocommerce-admin-dashboard.php index fa031a47a4d..f167ff49a11 100644 --- a/admin/woocommerce-admin-dashboard.php +++ b/admin/woocommerce-admin-dashboard.php @@ -9,76 +9,162 @@ // Only hook in admin parts if the user has admin access if (current_user_can('manage_woocommerce')) : - add_action('right_now_content_table_end', 'woocommerce_content_right_now'); - add_action('right_now_table_end', 'woocommerce_right_now'); add_action('wp_dashboard_setup', 'woocommerce_init_dashboard_widgets' ); add_action('admin_footer', 'woocommerce_dashboard_sales_js'); endif; /** - * Right now widget hooks/content + * WooCommerce Right Now widget. + * Adds a dashboard widget with shop statistics. */ -function woocommerce_content_right_now() { - +function woocommerce_dashboard_widget_right_now() { global $woocommerce; - ?> - -

- - - - - - - - - - - - - - - - - - count; - $completed_count = get_term_by( 'slug', 'completed', 'shop_order_status' )->count; - $on_hold_count = get_term_by( 'slug', 'on-hold', 'shop_order_status' )->count; - $processing_count = get_term_by( 'slug', 'processing', 'shop_order_status' )->count; + $product_count = wp_count_posts( 'product' ); + $product_cat_count = wp_count_terms( 'product_cat' ); + $product_tag_count = wp_count_terms( 'product_tag' ); + $product_attr_count = count( $woocommerce->get_attribute_taxonomies() ); + + $pending_count = get_term_by( 'slug', 'pending', 'shop_order_status' )->count; + $completed_count = get_term_by( 'slug', 'completed', 'shop_order_status' )->count; + $on_hold_count = get_term_by( 'slug', 'on-hold', 'shop_order_status' )->count; + $processing_count = get_term_by( 'slug', 'processing', 'shop_order_status' )->count; ?> -
publish ); - echo $num; - ?>
get_attribute_taxonomies()); - ?>
-

- - - - - - - - - - - - - - - - - + +
+

+
+ + + publish ); + $text = _n( 'Product', 'Products', intval($product_count->publish), 'woocommerce' ); + $link = add_query_arg( array( 'post_type' => 'product' ), get_admin_url( null, 'edit.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + + 'product_cat', 'post_type' => 'product' ), get_admin_url( null, 'edit-tags.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + + 'product_tag', 'post_type' => 'product' ), get_admin_url( null, 'edit-tags.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + + 'woocommerce_attributes' ), get_admin_url( null, 'admin.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + +
+ + +
+

+ + + + 'shop_order', 'shop_order_status' => 'pending' ), get_admin_url( null, 'edit.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + + 'shop_order', 'shop_order_status' => 'on-hold' ), get_admin_url( null, 'edit.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + + 'shop_order', 'shop_order_status' => 'processing' ), get_admin_url( null, 'edit.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + + 'product_cat', 'post_type' => 'completed' ), get_admin_url( null, 'edit-tags.php' ) ); + $num = '' . $num . ''; + $text = '' . $text . ''; + ?> + + + + + + + +
+
+ +
+ + WooCommerce %s.', 'woocommerce' ), WOOCOMMERCE_VERSION ); ?> + +
+
← '.date('F', strtotime('01-'.($the_month_num-1).'-2011')).''.__('Monthly Sales', 'woocommerce').''; + wp_add_dashboard_widget( 'woocommerce_dashboard_right_now', __( 'WooCommerce Right Now', 'woocommerce' ), 'woocommerce_dashboard_widget_right_now' ); wp_add_dashboard_widget('woocommerce_dashboard_sales', $sales_heading, 'woocommerce_dashboard_sales'); - wp_add_dashboard_widget('woocommerce_dashboard_recent_orders', __('WooCommerce recent orders', 'woocommerce'), 'woocommerce_dashboard_recent_orders'); - wp_add_dashboard_widget('woocommerce_dashboard_recent_reviews', __('WooCommerce recent reviews', 'woocommerce'), 'woocommerce_dashboard_recent_reviews'); + wp_add_dashboard_widget('woocommerce_dashboard_recent_orders', __('WooCommerce Recent Orders', 'woocommerce'), 'woocommerce_dashboard_recent_orders'); + wp_add_dashboard_widget('woocommerce_dashboard_recent_reviews', __('WooCommerce Recent Reviews', 'woocommerce'), 'woocommerce_dashboard_recent_reviews'); } /**