Merge pull request #26877 from woocommerce/fix/26547

Fixed WooCommerce menu for users that can only manage orders on WooCommerce
This commit is contained in:
Claudio Sanches 2020-07-08 12:08:29 -03:00 committed by GitHub
commit eeb08467af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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' );
}
/**

View File

@ -403,7 +403,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,
@ -467,7 +467,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,