Refactor so as to leave 'enabled' setting alone in case gateway was already enabled

This commit is contained in:
Paul Dechov 2018-01-16 15:51:34 -05:00
parent fcf3d368f2
commit dc884c5e2f
1 changed files with 5 additions and 5 deletions

View File

@ -1503,9 +1503,7 @@ class WC_Admin_Setup_Wizard {
$this->install_plugin( $gateway_id, $gateway );
}
$settings_key = 'woocommerce_' . $gateway_id . '_settings';
$settings = array_filter( (array) get_option( $settings_key, array() ) );
$settings['enabled'] = ! empty( $_POST[ 'wc-wizard-service-' . $gateway_id . '-enabled' ] ) ? 'yes' : 'no'; // WPCS: CSRF ok, input var ok.
$settings = array( 'enabled' => ! empty( $_POST[ 'wc-wizard-service-' . $gateway_id . '-enabled' ] ) ? 'yes' : 'no' ); // WPCS: CSRF ok, input var ok.
// @codingStandardsIgnoreStart
if ( ! empty( $gateway['settings'] ) ) {
@ -1518,10 +1516,12 @@ class WC_Admin_Setup_Wizard {
// @codingStandardsIgnoreSEnd
if ( 'ppec_paypal' === $gateway_id && empty( $settings['reroute_requests'] ) ) {
$settings['enabled'] = 'no';
unset( $settings['enabled'] );
}
update_option( $settings_key, $settings );
$settings_key = 'woocommerce_' . $gateway_id . '_settings';
$old_settings = array_filter( (array) get_option( $settings_key, array() ) );
update_option( $settings_key, array_merge( $old_settings, $settings ) );
}
wp_redirect( esc_url_raw( $this->get_next_step_link() ) );