From f643c516d1b499d62e61909cfd8535181878e28e Mon Sep 17 00:00:00 2001 From: parmarhardip Date: Wed, 24 Apr 2019 15:59:14 +0530 Subject: [PATCH 1/5] enhance #23381 Prevent the Cart, checkout and my account page from being set to the same page. --- .../admin/settings/class-wc-settings-advanced.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/admin/settings/class-wc-settings-advanced.php b/includes/admin/settings/class-wc-settings-advanced.php index f016534a4e2..bf626372053 100644 --- a/includes/admin/settings/class-wc-settings-advanced.php +++ b/includes/admin/settings/class-wc-settings-advanced.php @@ -89,6 +89,7 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'default' => '', 'class' => 'wc-enhanced-select-nostd', 'css' => 'min-width:300px;', + 'args' => array( 'exclude' => array( wc_get_page_id( 'cart' ), wc_get_page_id( 'myaccount' ) ) ), 'desc_tip' => true, ), @@ -101,6 +102,7 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'default' => '', 'class' => 'wc-enhanced-select-nostd', 'css' => 'min-width:300px;', + 'args' => array( 'exclude' => array( wc_get_page_id( 'cart' ), wc_get_page_id( 'checkout' ) ) ), 'desc_tip' => true, ), @@ -430,6 +432,19 @@ class WC_Settings_Advanced extends WC_Settings_Page { $_POST['woocommerce_terms_page_id'] = ''; } + // Prevent the Cart, checkout and my account page from being set to the same page. + if ( isset( $_POST['woocommerce_cart_page_id'], $_POST['woocommerce_checkout_page_id'], $_POST['woocommerce_myaccount_page_id'] ) ) { + if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { + $_POST['woocommerce_checkout_page_id'] = ''; + } + if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { + $_POST['woocommerce_myaccount_page_id'] = ''; + } + if ( $_POST['woocommerce_checkout_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { + $_POST['woocommerce_myaccount_page_id'] = ''; + } + } + WC_Admin_Settings::save_fields( $settings ); if ( $current_section ) { From 2122a84d8bbc33ef5b1cdb79a1a567f10abeab3b Mon Sep 17 00:00:00 2001 From: parmarhardip Date: Wed, 24 Apr 2019 16:34:28 +0530 Subject: [PATCH 2/5] - coding standard check --- includes/admin/settings/class-wc-settings-advanced.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/admin/settings/class-wc-settings-advanced.php b/includes/admin/settings/class-wc-settings-advanced.php index bf626372053..bfabddb6dd2 100644 --- a/includes/admin/settings/class-wc-settings-advanced.php +++ b/includes/admin/settings/class-wc-settings-advanced.php @@ -433,14 +433,14 @@ class WC_Settings_Advanced extends WC_Settings_Page { } // Prevent the Cart, checkout and my account page from being set to the same page. - if ( isset( $_POST['woocommerce_cart_page_id'], $_POST['woocommerce_checkout_page_id'], $_POST['woocommerce_myaccount_page_id'] ) ) { - if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { + if ( isset( $_POST['woocommerce_cart_page_id'], $_POST['woocommerce_checkout_page_id'], $_POST['woocommerce_myaccount_page_id'] ) ) { // WPCS: input var ok, CSRF ok. + if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { // WPCS: input var ok, CSRF ok. $_POST['woocommerce_checkout_page_id'] = ''; } - if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { + if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { // WPCS: input var ok, CSRF ok. $_POST['woocommerce_myaccount_page_id'] = ''; } - if ( $_POST['woocommerce_checkout_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { + if ( $_POST['woocommerce_checkout_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { // WPCS: input var ok, CSRF ok. $_POST['woocommerce_myaccount_page_id'] = ''; } } From 4c90f566bbf48a8016f7a07e98848ee8d6cc084e Mon Sep 17 00:00:00 2001 From: parmarhardip Date: Wed, 24 Apr 2019 17:31:20 +0530 Subject: [PATCH 3/5] - Prevent the Cart, checkout and my account page from being set to the same page. --- includes/admin/settings/class-wc-settings-advanced.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/admin/settings/class-wc-settings-advanced.php b/includes/admin/settings/class-wc-settings-advanced.php index bfabddb6dd2..cd9664561b1 100644 --- a/includes/admin/settings/class-wc-settings-advanced.php +++ b/includes/admin/settings/class-wc-settings-advanced.php @@ -77,6 +77,7 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'default' => '', 'class' => 'wc-enhanced-select-nostd', 'css' => 'min-width:300px;', + 'args' => array( 'exclude' => array( wc_get_page_id( 'checkout' ), wc_get_page_id( 'myaccount' ) ) ), 'desc_tip' => true, ), From 7b8d7d7390350de990e11b50d6392ef334d7a375 Mon Sep 17 00:00:00 2001 From: parmarhardip Date: Wed, 24 Apr 2019 19:03:19 +0530 Subject: [PATCH 4/5] - autoload false and check Travis CI build --- .../settings/class-wc-settings-advanced.php | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/includes/admin/settings/class-wc-settings-advanced.php b/includes/admin/settings/class-wc-settings-advanced.php index cd9664561b1..7ad42ab2702 100644 --- a/includes/admin/settings/class-wc-settings-advanced.php +++ b/includes/admin/settings/class-wc-settings-advanced.php @@ -51,6 +51,7 @@ class WC_Settings_Advanced extends WC_Settings_Page { * Get settings array. * * @param string $current_section Current section slug. + * * @return array */ public function get_settings( $current_section = '' ) { @@ -77,8 +78,15 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'default' => '', 'class' => 'wc-enhanced-select-nostd', 'css' => 'min-width:300px;', - 'args' => array( 'exclude' => array( wc_get_page_id( 'checkout' ), wc_get_page_id( 'myaccount' ) ) ), + 'args' => array( + 'exclude' => + array( + wc_get_page_id( 'checkout' ), + wc_get_page_id( 'myaccount' ) + ) + ), 'desc_tip' => true, + 'autoload' => false, ), array( @@ -90,8 +98,15 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'default' => '', 'class' => 'wc-enhanced-select-nostd', 'css' => 'min-width:300px;', - 'args' => array( 'exclude' => array( wc_get_page_id( 'cart' ), wc_get_page_id( 'myaccount' ) ) ), + 'args' => array( + 'exclude' => + array( + wc_get_page_id( 'cart' ), + wc_get_page_id( 'myaccount' ) + ) + ), 'desc_tip' => true, + 'autoload' => false, ), array( @@ -103,8 +118,15 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'default' => '', 'class' => 'wc-enhanced-select-nostd', 'css' => 'min-width:300px;', - 'args' => array( 'exclude' => array( wc_get_page_id( 'cart' ), wc_get_page_id( 'checkout' ) ) ), + 'args' => array( + 'exclude' => + array( + wc_get_page_id( 'cart' ), + wc_get_page_id( 'checkout' ) + ) + ), 'desc_tip' => true, + 'autoload' => false, ), array( @@ -131,7 +153,7 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'id' => 'checkout_process_options', ), - 'force_ssl_checkout' => array( + 'force_ssl_checkout' => array( 'title' => __( 'Secure checkout', 'woocommerce' ), 'desc' => __( 'Force secure checkout', 'woocommerce' ), 'id' => 'woocommerce_force_ssl_checkout', @@ -384,7 +406,9 @@ class WC_Settings_Advanced extends WC_Settings_Page { * Form method. * * @deprecated 3.4.4 + * * @param string $method Method name. + * * @return string */ public function form_method( $method ) { @@ -461,6 +485,7 @@ class WC_Settings_Advanced extends WC_Settings_Page { * @deprecated 3.4 in favour of WC_Settings_Advanced. * @todo remove in 4.0. */ -class WC_Settings_Rest_API extends WC_Settings_Advanced {} // @codingStandardsIgnoreLine. +class WC_Settings_Rest_API extends WC_Settings_Advanced { +} // @codingStandardsIgnoreLine. return new WC_Settings_Advanced(); From 8ffd78372f1eecd5c771fbf49240c47429b18659 Mon Sep 17 00:00:00 2001 From: parmarhardip Date: Thu, 25 Apr 2019 10:25:17 +0530 Subject: [PATCH 5/5] - coding standard improve --- .../admin/settings/class-wc-settings-advanced.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/admin/settings/class-wc-settings-advanced.php b/includes/admin/settings/class-wc-settings-advanced.php index 7ad42ab2702..dfbd8b2356d 100644 --- a/includes/admin/settings/class-wc-settings-advanced.php +++ b/includes/admin/settings/class-wc-settings-advanced.php @@ -82,8 +82,8 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'exclude' => array( wc_get_page_id( 'checkout' ), - wc_get_page_id( 'myaccount' ) - ) + wc_get_page_id( 'myaccount' ), + ), ), 'desc_tip' => true, 'autoload' => false, @@ -102,8 +102,8 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'exclude' => array( wc_get_page_id( 'cart' ), - wc_get_page_id( 'myaccount' ) - ) + wc_get_page_id( 'myaccount' ), + ), ), 'desc_tip' => true, 'autoload' => false, @@ -122,8 +122,8 @@ class WC_Settings_Advanced extends WC_Settings_Page { 'exclude' => array( wc_get_page_id( 'cart' ), - wc_get_page_id( 'checkout' ) - ) + wc_get_page_id( 'checkout' ), + ), ), 'desc_tip' => true, 'autoload' => false,