diff --git a/includes/Vendor/SetupWizard.php b/includes/Vendor/SetupWizard.php index 84dda3439..e1f2cb33a 100644 --- a/includes/Vendor/SetupWizard.php +++ b/includes/Vendor/SetupWizard.php @@ -78,10 +78,13 @@ public function setup_wizard() { // 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 ) ); + $this->current_step = sanitize_key( wp_unslash( $_GET['step'] ) ) ?? $this->get_first_step(); } - if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->current_step ]['handler'] ) ) { // WPCS: CSRF ok. + if ( ! isset( $this->steps[ $this->current_step ]['handler'] ) ) { + $this->current_step = $this->get_first_step(); + } + if ( ! empty( $_POST['save_step'] ) ) { // WPCS: CSRF ok. call_user_func( $this->steps[ $this->current_step ]['handler'] ); } @@ -166,7 +169,7 @@ public function dokan_setup_introduction() {
steps = apply_filters( 'dokan_seller_wizard_steps', $steps ); - $this->current_step = current( array_keys( $this->steps ) ); + $this->current_step = $this->get_first_step(); + } + + protected function get_first_step() { + return current( array_keys( $this->steps ) ); } }