From 3f9714653cc35f053c63ebe539caa1bc20529c0b Mon Sep 17 00:00:00 2001 From: osman sufy Date: Wed, 20 Nov 2024 11:00:03 +0600 Subject: [PATCH] check invalid step --- includes/Vendor/SetupWizard.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 ) ); } }