-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Skip] payment in Setup wizard when no payment is active #2468
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
class SetupWizard { | ||
|
||
/** @var string Currenct Step */ | ||
protected $step = ''; | ||
protected string $current_step = ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure PHP Version Compatibility with Typed Properties The use of typed properties, such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the /** @var string custom logo url of the theme */
protected $custom_logo = ''; |
||
|
||
/** @var array Steps for the setup wizard */ | ||
protected $steps = []; | ||
|
@@ -266,10 +266,10 @@ public function setup_wizard() { | |
unset( $this->steps['recommended'] ); | ||
} | ||
|
||
$this->step = current( array_keys( $this->steps ) ); | ||
$this->current_step = current( array_keys( $this->steps ) ); | ||
// 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->step = sanitize_key( wp_unslash( $_GET['step'] ) ); | ||
$this->current_step = sanitize_key( wp_unslash( $_GET['step'] ) ); | ||
} | ||
|
||
$this->enqueue_scripts(); | ||
|
@@ -278,8 +278,8 @@ public function setup_wizard() { | |
isset( $_POST['_wpnonce'], $_POST['save_step'] ) | ||
&& wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'dokan-setup' ) | ||
&& ! empty( $_POST['save_step'] ) | ||
&& isset( $this->steps[ $this->step ]['handler'] ) ) { | ||
call_user_func_array( $this->steps[ $this->step ]['handler'], [ $this ] ); | ||
&& isset( $this->steps[ $this->current_step ]['handler'] ) ) { | ||
call_user_func_array( $this->steps[ $this->current_step ]['handler'], [ $this ] ); | ||
} | ||
|
||
ob_start(); | ||
|
@@ -292,7 +292,7 @@ public function get_next_step_link() { | |
|
||
return add_query_arg( | ||
[ | ||
'step' => $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ], | ||
'step' => $keys[ array_search( $this->current_step, array_keys( $this->steps ), true ) + 1 ], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle Potential Array Offset Error in When calculating the next step, Apply this diff to handle the array offset error: public function get_next_step_link() {
$keys = array_keys( $this->steps );
- return add_query_arg(
- [
- 'step' => $keys[ array_search( $this->current_step, array_keys( $this->steps ), true ) + 1 ],
- '_admin_sw_nonce' => wp_create_nonce( 'dokan_admin_setup_wizard_nonce' ),
- ]
- );
+ $current_index = array_search( $this->current_step, $keys, true );
+ if ( false !== $current_index && isset( $keys[ $current_index + 1 ] ) ) {
+ $next_step = $keys[ $current_index + 1 ];
+ } else {
+ $next_step = '';
+ }
+ return add_query_arg(
+ [
+ 'step' => $next_step,
+ '_admin_sw_nonce' => wp_create_nonce( 'dokan_admin_setup_wizard_nonce' ),
+ ]
+ );
}
|
||
'_admin_sw_nonce' => wp_create_nonce( 'dokan_admin_setup_wizard_nonce' ), | ||
] | ||
); | ||
|
@@ -328,7 +328,7 @@ public function setup_wizard_header() { | |
*/ | ||
public function setup_wizard_footer() { | ||
?> | ||
<?php if ( 'next_steps' === $this->step ) : ?> | ||
<?php if ( 'next_steps' === $this->current_step ) : ?> | ||
<a class="wc-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'dokan-lite' ); ?></a> | ||
<?php endif; ?> | ||
</body> | ||
|
@@ -347,9 +347,9 @@ public function setup_wizard_steps() { | |
<?php foreach ( $ouput_steps as $step_key => $step ) : ?> | ||
<li class=" | ||
<?php | ||
if ( $step_key === $this->step ) { | ||
if ( $step_key === $this->current_step ) { | ||
echo 'active'; | ||
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) { | ||
} elseif ( array_search( $this->current_step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) { | ||
echo 'done'; | ||
} | ||
?> | ||
|
@@ -363,13 +363,13 @@ public function setup_wizard_steps() { | |
* Output the content for the current step. | ||
*/ | ||
public function setup_wizard_content() { | ||
if ( empty( $this->steps[ $this->step ]['view'] ) ) { | ||
if ( empty( $this->steps[ $this->current_step ]['view'] ) ) { | ||
wp_safe_redirect( esc_url_raw( add_query_arg( 'step', 'introduction' ) ) ); | ||
exit; | ||
} | ||
|
||
echo '<div class="wc-setup-content">'; | ||
call_user_func( $this->steps[ $this->step ]['view'] ); | ||
call_user_func( $this->steps[ $this->current_step ]['view'] ); | ||
echo '</div>'; | ||
} | ||
|
||
|
@@ -500,7 +500,7 @@ public function dokan_setup_selling() { | |
/** | ||
* Commission step. | ||
* | ||
* @since 3.14.0 | ||
* @since DOKAN_SINCE | ||
* | ||
* @return void | ||
*/ | ||
|
@@ -547,7 +547,7 @@ public function dokan_setup_selling_save() { | |
/** | ||
* Save commission options. | ||
* | ||
* @since 3.14.0 | ||
* @since DOKAN_SINCE | ||
* | ||
* @return void | ||
*/ | ||
|
@@ -831,12 +831,12 @@ public function dokan_setup_withdraw_save() { | |
$options['withdraw_methods'] = ! empty( $_POST['withdraw_methods'] ) ? wc_clean( wp_unslash( $_POST['withdraw_methods'] ) ) : []; | ||
$options['withdraw_order_status'] = ! empty( $_POST['withdraw_order_status'] ) ? wc_clean( wp_unslash( $_POST['withdraw_order_status'] ) ) : []; | ||
|
||
if ( ! empty( $_POST['withdraw_limit'] ) ) { | ||
$input_limit = sanitize_text_field( wp_unslash( $_POST['withdraw_limit'] ) ); | ||
$options['withdraw_limit'] = is_numeric( $input_limit ) && $input_limit >= 0 ? wc_format_decimal( $input_limit ) : 0; | ||
} else { | ||
$options['withdraw_limit'] = 0; | ||
} | ||
if ( ! empty( $_POST['withdraw_limit'] ) ) { | ||
$input_limit = sanitize_text_field( wp_unslash( $_POST['withdraw_limit'] ) ); | ||
$options['withdraw_limit'] = is_numeric( $input_limit ) && $input_limit >= 0 ? wc_format_decimal( $input_limit ) : 0; | ||
} else { | ||
$options['withdraw_limit'] = 0; | ||
} | ||
|
||
/** | ||
* Filter dokan_withdraw options before saving in setup wizard | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls fix the typo Currenct