Skip to content

Commit

Permalink
[update] [refactor] SetupWizard.php
Browse files Browse the repository at this point in the history
  • Loading branch information
osmansufy committed Nov 19, 2024
1 parent e35a0c3 commit f41d261
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions includes/Vendor/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ public function setup_wizard() {
// Setup wizard steps
$this->set_steps();

// If payment step is accessed but no active methods exist, redirect to next step
if ( isset( $_GET['step'] ) && 'payment' === $_GET['step'] ) {
$active_methods = dokan_withdraw_get_active_methods();
if ( empty( $active_methods ) ) {
wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit;
}
}

// get step from url
if ( isset( $_GET['_admin_sw_nonce'], $_GET['step'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_admin_sw_nonce'] ) ), 'dokan_admin_setup_wizard_nonce' ) ) {
$this->current_step = sanitize_key( wp_unslash( $_GET['step'] ) ) ?? current( array_keys( $this->steps ) );
Expand Down Expand Up @@ -532,6 +523,11 @@ public function dokan_setup_store_save() {
public function dokan_setup_payment() {
$methods = dokan_withdraw_get_active_methods();
$store_info = $this->store_info;
// If payment step is accessed but no active methods exist, redirect to next step
if ( 'payment' === $this->current_step && empty( $methods ) ) {
wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit; }

?>
<h1><?php esc_html_e( 'Payment Setup', 'dokan-lite' ); ?></h1>
<form method="post" id='dokan-seller-payment-setup-form' novalidate>
Expand Down Expand Up @@ -670,13 +666,14 @@ public function get_next_step_link(): string {
++$step;

// If next step is payment but there are no active methods, skip to the following step
if ( 'payment' === $keys[ $step ] && empty( dokan_withdraw_get_active_methods() ) ) {
if ( 'payment' === ( $keys[ $step ] ?? '' ) && empty( dokan_withdraw_get_active_methods() ) ) {
++$step;
}
$next_step = $keys[ $step ] ?? '';
$next_step = apply_filters( 'dokan_seller_wizard_next_step', $next_step, $this->current_step, $this->steps );
return add_query_arg(
[
'step' => apply_filters( 'dokan_seller_wizard_next_step', $next_step, $this->current_step, $this->steps ),
'step' => $next_step,
'_admin_sw_nonce' => wp_create_nonce( 'dokan_admin_setup_wizard_nonce' ),
]
);
Expand Down

0 comments on commit f41d261

Please sign in to comment.