Skip to content

Commit 29b5f57

Browse files
committed
refactor: improve settings wizard flow and completion page layout
1 parent 4fc916d commit 29b5f57

4 files changed

Lines changed: 18 additions & 22 deletions

File tree

includes/admin/class-settings-wizard.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,16 @@ public function get_wizard_steps() {
138138
'description' => __( 'Upgrade to Contextual Related Posts Pro to unlock advanced features such as custom tables, advanced weighting, and more. <strong>Take your related posts to the next level!</strong>', 'contextual-related-posts' ) . '<br /><br /><a href="https://webberzone.com/plugins/contextual-related-posts/pro/" target="_blank" class="button button-primary">' . __( 'Learn more about Pro', 'contextual-related-posts' ) . '</a>',
139139
'settings' => $this->build_step_settings( $pro_features_keys, $all_settings ),
140140
),
141-
'completion' => array(
142-
'title' => __( 'Setup Complete!', 'contextual-related-posts' ),
143-
'description' => __( 'Your Contextual Related Posts plugin has been configured successfully.', 'contextual-related-posts' ),
144-
'settings' => array(),
145-
),
146141
);
147142

148143
// Add custom tables indexing step if custom tables are enabled.
149144
if ( crp_get_option( 'use_custom_tables', false ) ) {
150-
// Insert the custom tables step before completion.
151-
$completion_step = $steps['completion'];
152-
unset( $steps['completion'] );
153-
154145
$steps['custom_tables_index'] = array(
155146
'title' => __( 'Index Custom Tables', 'contextual-related-posts' ),
156147
'description' => __( 'Custom tables have been enabled. Index your content to improve search performance and enable advanced features.', 'contextual-related-posts' ),
157148
'settings' => array(),
158149
'custom_step' => true, // Flag to indicate this needs custom rendering.
159150
);
160-
161-
$steps['completion'] = $completion_step;
162151
}
163152

164153
/**
@@ -574,7 +563,7 @@ protected function render_completion_page() {
574563

575564
<div class="wizard-completion-content">
576565
<div class="wizard-completion-features">
577-
<h3><?php esc_html_e( 'What\'s Next?', 'contextual-related-posts' ); ?></h3>
566+
<h3><?php esc_html_e( "What's Next?", 'contextual-related-posts' ); ?></h3>
578567
<ul>
579568
<li><?php esc_html_e( 'Visit your site to see related posts in action', 'contextual-related-posts' ); ?></li>
580569
<li><?php esc_html_e( 'Customize the display using the settings page', 'contextual-related-posts' ); ?></li>

includes/admin/settings/class-settings-wizard-api.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ public function process_step() {
293293

294294
case 'finish_setup':
295295
$this->process_current_step();
296-
$this->complete_wizard();
297-
$this->redirect_to_admin();
296+
$this->mark_wizard_completed();
297+
$this->redirect_to_step( $this->total_steps + 1 );
298298
break;
299299

300300
case 'skip_wizard':
@@ -432,9 +432,9 @@ protected function redirect_to_admin() {
432432
}
433433

434434
/**
435-
* Complete the wizard.
435+
* Mark the wizard as completed without redirecting.
436436
*/
437-
protected function complete_wizard() {
437+
protected function mark_wizard_completed() {
438438
update_option( "{$this->prefix}_wizard_completed", true );
439439
update_option( "{$this->prefix}_wizard_completed_date", current_time( 'mysql' ) );
440440

@@ -448,6 +448,13 @@ protected function complete_wizard() {
448448
* @param string $prefix Plugin prefix.
449449
*/
450450
do_action( "{$this->prefix}_wizard_completed", $this->prefix );
451+
}
452+
453+
/**
454+
* Complete the wizard.
455+
*/
456+
protected function complete_wizard() {
457+
$this->mark_wizard_completed();
451458

452459
// Redirect to completion page or main settings.
453460
wp_safe_redirect( $this->get_completion_redirect_url() );
@@ -464,9 +471,9 @@ public function get_current_step() {
464471
// phpcs:disable WordPress.Security.NonceVerification.Recommended
465472
if ( isset( $_GET['step'] ) ) {
466473
$step = absint( $_GET['step'] );
467-
if ( $step > 0 && $step <= $this->total_steps ) {
474+
if ( $step > 0 && $step <= $this->total_steps + 1 ) {
468475
$this->current_step = $step;
469-
$this->update_current_step(); // Update the database to match URL.
476+
$this->update_current_step();
470477
return $this->current_step;
471478
}
472479
}

includes/admin/settings/css/wizard.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172

173173
/* Completion Page */
174174
.wizard-complete {
175-
text-align: center;
175+
text-align: left;
176176
}
177177

178178
.wizard-completion-header {
@@ -204,8 +204,6 @@
204204
margin-bottom: 30px;
205205
text-align: left;
206206
max-width: 500px;
207-
margin-left: auto;
208-
margin-right: auto;
209207
}
210208

211209
.wizard-completion-features h3 {
@@ -217,11 +215,13 @@
217215
.wizard-completion-features ul {
218216
margin: 0;
219217
padding-left: 20px;
218+
list-style-type: disc;
220219
}
221220

222221
.wizard-completion-features li {
223222
margin-bottom: 8px;
224223
line-height: 1.4;
224+
list-style-type: disc;
225225
}
226226

227227
.wizard-completion-actions {

includes/admin/settings/css/wizard.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)