From 054ca44c6325f1e2b943a1d2a6d46360ba5d60e9 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 19 Mar 2012 20:29:04 +0100 Subject: [PATCH] Fixed highlighting in admin menu for post type add screens. Closes #836. --- admin/woocommerce-admin-init.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/admin/woocommerce-admin-init.php b/admin/woocommerce-admin-init.php index f11562aa647..4c0d9650112 100644 --- a/admin/woocommerce-admin-init.php +++ b/admin/woocommerce-admin-init.php @@ -34,6 +34,24 @@ function woocommerce_admin_menu() { foreach ($print_css_on as $page) add_action( 'admin_print_styles-'. $page, 'woocommerce_admin_css' ); } +/** + * Highlights the correct top level admin menu item for post type add screens. + */ +add_action( 'admin_head', 'woocommerce_admin_menu_highlight' ); + +function woocommerce_admin_menu_highlight() { + global $parent_file, $submenu_file, $post_type; + + $to_highlight = array( 'shop_order', 'shop_coupon' ); + + if ( isset( $post_type ) ) { + if ( in_array( $post_type, $to_highlight ) ) { + $submenu_file = 'edit.php?post_type=' . $post_type; + $parent_file = 'woocommerce'; + } + } +} + /** * Admin Notices */