From 43a2bb2a2496461f996cded221b4ecd72a922beb Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Wed, 7 Apr 2021 15:35:28 +0200 Subject: [PATCH 1/2] Don't show the "WooCommerce Setup" widget in dashboard if WC Admin is disabled --- includes/admin/class-wc-admin-dashboard-setup.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/admin/class-wc-admin-dashboard-setup.php b/includes/admin/class-wc-admin-dashboard-setup.php index 0fb9f7cda83..580bdc00b2e 100644 --- a/includes/admin/class-wc-admin-dashboard-setup.php +++ b/includes/admin/class-wc-admin-dashboard-setup.php @@ -162,7 +162,9 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : * @return bool */ private function should_display_widget() { - return 'yes' !== get_option( 'woocommerce_task_list_complete' ) && 'yes' !== get_option( 'woocommerce_task_list_hidden' ); + return WC()->is_wc_admin_active() && + 'yes' !== get_option( 'woocommerce_task_list_complete' ) && + 'yes' !== get_option( 'woocommerce_task_list_hidden' ); } /** From 1cf6b9d39e7a74cb8da748731785f5dae3edec72 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 8 Apr 2021 09:31:51 +0200 Subject: [PATCH 2/2] Extra check for not showing the "WooCommerce Setup" widget in dashboard if WC Admin is disabled --- includes/admin/class-wc-admin-dashboard.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/admin/class-wc-admin-dashboard.php b/includes/admin/class-wc-admin-dashboard.php index 498eeee78ae..6357b46e8bd 100644 --- a/includes/admin/class-wc-admin-dashboard.php +++ b/includes/admin/class-wc-admin-dashboard.php @@ -63,6 +63,10 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : * @return bool */ private function should_display_widget() { + if ( ! WC()->is_wc_admin_active() ) { + return false; + } + $has_permission = current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ); $task_completed_or_hidden = 'yes' === get_option( 'woocommerce_task_list_complete' ) || 'yes' === get_option( 'woocommerce_task_list_hidden' ); return $task_completed_or_hidden && $has_permission; @@ -127,11 +131,11 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : $reports = new WC_Admin_Report(); - $net_sales_link = 'admin.php?page=wc-reports&tab=orders&range=month'; + $net_sales_link = 'admin.php?page=wc-reports&tab=orders&range=month'; $top_seller_link = 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids='; - $report_data = $is_wc_admin_disabled ? $this->get_sales_report_data() : $this->get_wc_admin_performance_data(); + $report_data = $is_wc_admin_disabled ? $this->get_sales_report_data() : $this->get_wc_admin_performance_data(); if ( ! $is_wc_admin_disabled ) { - $net_sales_link = 'admin.php?page=wc-admin&path=%2Fanalytics%2Frevenue&chart=net_revenue&orderby=net_revenue&period=month&compare=previous_period'; + $net_sales_link = 'admin.php?page=wc-admin&path=%2Fanalytics%2Frevenue&chart=net_revenue&orderby=net_revenue&period=month&compare=previous_period'; $top_seller_link = 'admin.php?page=wc-admin&filter=single_product&path=%2Fanalytics%2Fproducts&products='; }