From 868b3c149cf8cd8e7e0db8dd33afb58fcecb6ac9 Mon Sep 17 00:00:00 2001 From: paul sealock Date: Wed, 29 May 2024 22:39:02 +1200 Subject: [PATCH] cleanup --- plugins/woocommerce-admin/client/settings/content.js | 5 ++++- plugins/woocommerce-admin/client/settings/style.scss | 4 ++++ plugins/woocommerce/client/admin/config/core.json | 2 +- .../includes/admin/settings/class-wc-settings-page.php | 4 +++- plugins/woocommerce/src/Admin/Features/Settings.php | 10 +++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce-admin/client/settings/content.js b/plugins/woocommerce-admin/client/settings/content.js index 913028601d1..240a245c025 100644 --- a/plugins/woocommerce-admin/client/settings/content.js +++ b/plugins/woocommerce-admin/client/settings/content.js @@ -14,7 +14,10 @@ export const Content = ( { data } ) => { switch ( setting.type ) { case 'title': return ( -
+

{ setting.title }

); diff --git a/plugins/woocommerce-admin/client/settings/style.scss b/plugins/woocommerce-admin/client/settings/style.scss index c77aa56c963..91b6df17aef 100644 --- a/plugins/woocommerce-admin/client/settings/style.scss +++ b/plugins/woocommerce-admin/client/settings/style.scss @@ -62,6 +62,10 @@ justify-content: space-between; margin: 16px 0px; + &:first-of-type { + margin: 0; + } + h4 { margin: 0; width: 200px; diff --git a/plugins/woocommerce/client/admin/config/core.json b/plugins/woocommerce/client/admin/config/core.json index 2597d9002a3..a26772d167d 100644 --- a/plugins/woocommerce/client/admin/config/core.json +++ b/plugins/woocommerce/client/admin/config/core.json @@ -26,7 +26,7 @@ "remote-free-extensions": true, "payment-gateway-suggestions": true, "printful": false, - "settings": true, + "settings": false, "shipping-label-banner": true, "subscriptions": true, "store-alerts": true, diff --git a/plugins/woocommerce/includes/admin/settings/class-wc-settings-page.php b/plugins/woocommerce/includes/admin/settings/class-wc-settings-page.php index c8b6993b683..93554ffebfd 100644 --- a/plugins/woocommerce/includes/admin/settings/class-wc-settings-page.php +++ b/plugins/woocommerce/includes/admin/settings/class-wc-settings-page.php @@ -99,7 +99,9 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) : $section_settings_data = array(); foreach( $section_settings as $section_setting ) { - $section_setting['value'] = get_option( $section_setting['id'], $section_setting['default'] ); + if ( isset( $section_setting['id'] ) ) { + $section_setting['value'] = isset( $section_setting['default'] ) ? get_option( $section_setting['id'], $section_setting['default'] ) : get_option( $section_setting['id'] ); + } $section_settings_data[] = $section_setting; } $sections_data[ $section_id ] = array( diff --git a/plugins/woocommerce/src/Admin/Features/Settings.php b/plugins/woocommerce/src/Admin/Features/Settings.php index 22534c321d1..935aa49d29d 100644 --- a/plugins/woocommerce/src/Admin/Features/Settings.php +++ b/plugins/woocommerce/src/Admin/Features/Settings.php @@ -54,7 +54,15 @@ class Settings { return $settings; } - // TODO: change so its only being added on Settings page, otherwise bail. + // phpcs:disable WordPress.Security.NonceVerification.Recommended + $page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); + $path = sanitize_text_field( wp_unslash( $_GET['path'] ) ); + + // Only add data when we are on the settings page. + if ( 'wc-admin' !== $page && 0 !== strpos( $path, '/settings' ) ) { + return $settings; + } + // phpcs:enable $setting_pages = \WC_Admin_Settings::get_settings_pages(); $pages = array();