From 9d2a493cea6bbb742db0efc7fac428a519a95aa6 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 25 Oct 2017 12:51:19 +0100 Subject: [PATCH] Prevent notice on settings page when accessing invalid tab Closes #17367 --- .../admin/settings/class-wc-settings-tax.php | 8 ++++++- includes/admin/views/html-admin-settings.php | 23 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/includes/admin/settings/class-wc-settings-tax.php b/includes/admin/settings/class-wc-settings-tax.php index 9dcd44034af..8df905a5bb2 100644 --- a/includes/admin/settings/class-wc-settings-tax.php +++ b/includes/admin/settings/class-wc-settings-tax.php @@ -28,7 +28,13 @@ class WC_Settings_Tax extends WC_Settings_Page { $this->id = 'tax'; $this->label = __( 'Tax', 'woocommerce' ); - parent::__construct(); + add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); + + if ( wc_tax_enabled() ) { + add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) ); + add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) ); + add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) ); + } } /** diff --git a/includes/admin/views/html-admin-settings.php b/includes/admin/views/html-admin-settings.php index a4244710bc5..fb1f126eae5 100644 --- a/includes/admin/views/html-admin-settings.php +++ b/includes/admin/views/html-admin-settings.php @@ -1,23 +1,36 @@
-

+