From e9aa903fc6eb6ebc8cae1375e5cb826796ab7346 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 10 May 2019 14:34:45 -0300 Subject: [PATCH] update default capability for analytics report to view_woocommerce_reports --- .../woocommerce-admin/includes/class-wc-admin-loader.php | 9 ++++++--- .../features/analytics/class-wc-admin-analytics.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce-admin/includes/class-wc-admin-loader.php b/plugins/woocommerce-admin/includes/class-wc-admin-loader.php index d06f2e83641..65fe25ac954 100644 --- a/plugins/woocommerce-admin/includes/class-wc-admin-loader.php +++ b/plugins/woocommerce-admin/includes/class-wc-admin-loader.php @@ -20,14 +20,16 @@ if ( ! function_exists( 'wc_admin_register_page' ) ) { */ function wc_admin_register_page( $options ) { $defaults = array( - 'parent' => '/analytics', + 'parent' => '/analytics', + 'capability' => 'view_woocommerce_reports', ); $options = wp_parse_args( $options, $defaults ); + add_submenu_page( '/' === $options['parent'][0] ? "wc-admin#{$options['parent']}" : $options['parent'], $options['title'], $options['title'], - 'manage_options', + $options['capability'], "wc-admin#{$options['path']}", array( 'WC_Admin_Loader', 'page_wrapper' ) ); @@ -171,11 +173,12 @@ class WC_Admin_Loader { $menu_title = __( 'Dashboard', 'woocommerce-admin' ); } + $analytics_cap = apply_filters( 'woocommerce_admin_analytics_menu_capability', 'view_woocommerce_reports' ); add_submenu_page( 'woocommerce', $page_title, $menu_title, - 'manage_options', + $analytics_cap, 'wc-admin', array( 'WC_Admin_Loader', 'page_wrapper' ) ); diff --git a/plugins/woocommerce-admin/includes/features/analytics/class-wc-admin-analytics.php b/plugins/woocommerce-admin/includes/features/analytics/class-wc-admin-analytics.php index 8baac3660c7..ccad4abe028 100644 --- a/plugins/woocommerce-admin/includes/features/analytics/class-wc-admin-analytics.php +++ b/plugins/woocommerce-admin/includes/features/analytics/class-wc-admin-analytics.php @@ -76,7 +76,7 @@ class WC_Admin_Analytics { add_menu_page( __( 'WooCommerce Analytics', 'woocommerce-admin' ), __( 'Analytics', 'woocommerce-admin' ), - 'manage_options', + 'view_woocommerce_reports', 'wc-admin#/analytics/revenue', array( 'WC_Admin_Loader', 'page_wrapper' ), 'dashicons-chart-bar',