From 6a0d5ebf0cfdb44191957a841b67d3af8110a735 Mon Sep 17 00:00:00 2001 From: claudiosmweb Date: Mon, 15 Sep 2014 23:32:34 -0300 Subject: [PATCH] Fixed number of processing orders display Reported in http://wordpress.org/support/topic/number-of-processing-orders-missing-from-left-panel Cannot use wc_get_order_type() before wc_register_order_type() @mikejolley --- includes/admin/class-wc-admin-menus.php | 44 ++++++++++++------------- includes/class-wc-post-types.php | 8 +---- readme.txt | 1 + 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/includes/admin/class-wc-admin-menus.php b/includes/admin/class-wc-admin-menus.php index b0dd30e086b..84e1a50940f 100644 --- a/includes/admin/class-wc-admin-menus.php +++ b/includes/admin/class-wc-admin-menus.php @@ -5,10 +5,12 @@ * @author WooThemes * @category Admin * @package WooCommerce/Admin - * @version 2.1.0 + * @version 2.2.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} if ( ! class_exists( 'WC_Admin_Menus' ) ) : @@ -42,12 +44,13 @@ class WC_Admin_Menus { public function admin_menu() { global $menu; - if ( current_user_can( 'manage_woocommerce' ) ) - $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); + if ( current_user_can( 'manage_woocommerce' ) ) { + $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); + } - $main_page = add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'manage_woocommerce', 'woocommerce' , null, null, '55.5' ); + $main_page = add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'manage_woocommerce', 'woocommerce', null, null, '55.5' ); - add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'product_attributes', array( $this, 'attributes_page' ) ); + add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'product_attributes', array( $this, 'attributes_page' ) ); } /** @@ -92,7 +95,6 @@ class WC_Admin_Menus { /** * Highlights the correct top level admin menu item for post type add screens. * - * @access public * @return void */ public function menu_highlight() { @@ -121,19 +123,16 @@ class WC_Admin_Menus { unset( $submenu['woocommerce'][1] ); } - // Sort out Orders menu when on the top level - if ( ! current_user_can( 'manage_woocommerce' ) ) { - foreach ( $menu as $key => $menu_item ) { - if ( strpos( $menu_item[0], _x('Orders', 'Admin menu name', 'woocommerce') ) === 0 ) { + if ( current_user_can( 'manage_woocommerce' ) ) { + foreach ( $submenu['woocommerce'] as $key => $menu_item ) { + if ( 0 === strpos( $menu_item[0], _x( 'Orders', 'Admin menu name', 'woocommerce' ) ) ) { - $menu_name = _x('Orders', 'Admin menu name', 'woocommerce'); - $menu_name_count = ''; + $menu_name = _x( 'Orders', 'Admin menu name', 'woocommerce' ); if ( $order_count = wc_processing_order_count() ) { - $menu_name_count = " " . number_format_i18n( $order_count ) . "" ; + $menu_name .= ' ' . number_format_i18n( $order_count ) . ''; } - $menu[$key][0] = $menu_name . $menu_name_count; - $submenu['edit.php?post_type=shop_order'][5][0] = $menu_name; + $submenu['woocommerce'][ $key ] [0] = $menu_name; break; } } @@ -157,26 +156,27 @@ class WC_Admin_Menus { $woocommerce_product = array_search( 'edit.php?post_type=product', $menu_order ); // Loop through menu order and do some rearranging - foreach ( $menu_order as $index => $item ) : + foreach ( $menu_order as $index => $item ) { - if ( ( ( 'woocommerce' ) == $item ) ) : + if ( ( ( 'woocommerce' ) == $item ) ) { $woocommerce_menu_order[] = 'separator-woocommerce'; $woocommerce_menu_order[] = $item; $woocommerce_menu_order[] = 'edit.php?post_type=product'; unset( $menu_order[$woocommerce_separator] ); unset( $menu_order[$woocommerce_product] ); - elseif ( !in_array( $item, array( 'separator-woocommerce' ) ) ) : + } elseif ( !in_array( $item, array( 'separator-woocommerce' ) ) ) { $woocommerce_menu_order[] = $item; - endif; + } - endforeach; + } // Return order return $woocommerce_menu_order; } /** - * custom_menu_order + * Custom menu order + * * @return bool */ public function custom_menu_order() { diff --git a/includes/class-wc-post-types.php b/includes/class-wc-post-types.php index bdf13cc1c67..ed02587cd78 100644 --- a/includes/class-wc-post-types.php +++ b/includes/class-wc-post-types.php @@ -266,12 +266,6 @@ class WC_Post_types { ) ); - $menu_name = _x( 'Orders', 'Admin menu name', 'woocommerce' ); - - if ( $order_count = wc_processing_order_count() ) { - $menu_name .= ' ' . number_format_i18n( $order_count ) . ''; - } - wc_register_order_type( 'shop_order', apply_filters( 'woocommerce_register_post_type_shop_order', @@ -290,7 +284,7 @@ class WC_Post_types { 'not_found' => __( 'No Orders found', 'woocommerce' ), 'not_found_in_trash' => __( 'No Orders found in trash', 'woocommerce' ), 'parent' => __( 'Parent Orders', 'woocommerce' ), - 'menu_name' => $menu_name + 'menu_name' => _x( 'Orders', 'Admin menu name', 'woocommerce' ) ), 'description' => __( 'This is where store orders are stored.', 'woocommerce' ), 'public' => false, diff --git a/readme.txt b/readme.txt index 3cd2799f925..a0c85249f2e 100644 --- a/readme.txt +++ b/readme.txt @@ -143,6 +143,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - Number format when calculate the line items tax. * Fix - Language update/install in Multisites. * Fix - "Set product image" media gallery title in non-product post type. +* Fix - Number of processing orders in WooCommerce > Orders menu. * Tweak - Display of locale information on system status page. * Tweak - Removed postcode for Bahamas. * Tweak - In system status, show path to template file override.