Merge pull request #23479 from parmarhardip/23381

enhance #23381 Prevent the Cart, checkout and my account page from be…
This commit is contained in:
Gerhard Potgieter 2019-07-14 19:49:37 +02:00 committed by GitHub
commit eee56a254f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 2 deletions

View File

@ -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,7 +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' ),
),
),
'desc_tip' => true,
'autoload' => false,
),
array(
@ -89,7 +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' ),
),
),
'desc_tip' => true,
'autoload' => false,
),
array(
@ -101,7 +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' ),
),
),
'desc_tip' => true,
'autoload' => false,
),
array(
@ -128,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',
@ -381,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 ) {
@ -430,6 +457,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'] ) ) { // 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'] ) { // WPCS: input var ok, CSRF ok.
$_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'] = '';
}
}
WC_Admin_Settings::save_fields( $settings );
if ( $current_section ) {
@ -445,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();