Merge pull request #29613 from woocommerce/fix/29567

Don't show the "WooCommerce Setup" widget in dashboard if WC Admin is disabled
This commit is contained in:
Roy Ho 2021-04-08 05:39:32 -07:00 committed by GitHub
commit a8572e755c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

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

View File

@ -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;