From f5b9af859106502580f18931a69b3ded3ccb5281 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 25 Jun 2020 20:01:12 -0300 Subject: [PATCH] Keep WooCommerce menu structure if user can edit others shop orders --- includes/admin/class-wc-admin-menus.php | 8 ++++---- includes/class-wc-post-types.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/admin/class-wc-admin-menus.php b/includes/admin/class-wc-admin-menus.php index bc3f48b59b0..c1dada7e4a1 100644 --- a/includes/admin/class-wc-admin-menus.php +++ b/includes/admin/class-wc-admin-menus.php @@ -55,11 +55,11 @@ class WC_Admin_Menus { public function admin_menu() { global $menu; - if ( current_user_can( 'manage_woocommerce' ) ) { + if ( current_user_can( 'edit_others_shop_orders' ) ) { $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); // WPCS: override ok. } - add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'manage_woocommerce', 'woocommerce', null, null, '55.5' ); + add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'edit_others_shop_orders', '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' ) ); } @@ -68,7 +68,7 @@ class WC_Admin_Menus { * Add menu item. */ public function reports_menu() { - if ( current_user_can( 'manage_woocommerce' ) ) { + if ( current_user_can( 'edit_others_shop_orders' ) ) { add_submenu_page( 'woocommerce', __( 'Reports', 'woocommerce' ), __( 'Reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ) ); } else { add_menu_page( __( 'Sales reports', 'woocommerce' ), __( 'Sales reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ), null, '55.6' ); @@ -239,7 +239,7 @@ class WC_Admin_Menus { * @return bool */ public function custom_menu_order( $enabled ) { - return $enabled || current_user_can( 'manage_woocommerce' ); + return $enabled || current_user_can( 'edit_others_shop_orders' ); } /** diff --git a/includes/class-wc-post-types.php b/includes/class-wc-post-types.php index ab9dcbc07d2..c5d6e69a514 100644 --- a/includes/class-wc-post-types.php +++ b/includes/class-wc-post-types.php @@ -402,7 +402,7 @@ class WC_Post_Types { 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, - 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true, + 'show_in_menu' => current_user_can( 'edit_others_shop_orders' ) ? 'woocommerce' : true, 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, @@ -466,7 +466,7 @@ class WC_Post_Types { 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, - 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true, + 'show_in_menu' => current_user_can( 'edit_others_shop_orders' ) ? 'woocommerce' : true, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false,