| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for the MLSImport onboarding wizard |
| 4 |
* |
| 5 |
* This file provides the main structure for the onboarding wizard interface. |
| 6 |
* It displays the header, step navigation, and content for the current step. |
| 7 |
* |
| 8 |
* @link https://mlsimport.com/ |
| 9 |
* @since 6.1.0 |
| 10 |
* |
| 11 |
* @package Mlsimport |
| 12 |
* @subpackage Mlsimport/admin/partials |
| 13 |
*/ |
| 14 |
|
| 15 |
// If this file is called directly, abort. |
| 16 |
if (!defined('WPINC')) { |
| 17 |
die; |
| 18 |
} |
| 19 |
|
| 20 |
// Get all steps |
| 21 |
$steps = mlsimport_get_steps(); |
| 22 |
|
| 23 |
// Check if steps exist |
| 24 |
if (empty($steps) || !is_array($steps)) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
// Get current step |
| 29 |
$current_step = mlsimport_get_current_step(); |
| 30 |
|
| 31 |
// Get all step keys for progress calculation |
| 32 |
$step_keys = array_keys($steps); |
| 33 |
$current_step_index = array_search($current_step, $step_keys); |
| 34 |
$total_steps = count($steps); |
| 35 |
$progress_percentage = ($current_step_index / ($total_steps - 1)) * 100; |
| 36 |
|
| 37 |
// Get current step data |
| 38 |
$current_step_data = isset($steps[$current_step]) ? $steps[$current_step] : array( |
| 39 |
'title' => __('Unknown Step', 'mlsimport'), |
| 40 |
'description' => '', |
| 41 |
); |
| 42 |
|
| 43 |
// Check if we can go back |
| 44 |
$can_go_back = $current_step_index > 0; |
| 45 |
|
| 46 |
// Check if we're on the last step |
| 47 |
$is_last_step = $current_step_index === count($step_keys) - 1; |
| 48 |
|
| 49 |
// Get next/previous step URLs |
| 50 |
$next_step = $current_step_index < count($step_keys) - 1 ? $step_keys[$current_step_index + 1] : ''; |
| 51 |
$prev_step = $current_step_index > 0 ? $step_keys[$current_step_index - 1] : ''; |
| 52 |
|
| 53 |
$next_url = admin_url('admin.php?page=mlsimport-onboarding&step=' . $next_step); |
| 54 |
$prev_url = admin_url('admin.php?page=mlsimport-onboarding&step=' . $prev_step); |
| 55 |
|
| 56 |
?> |
| 57 |
<div class="mlsimport-wizard-wrap"> |
| 58 |
<div class="mlsimport-wizard-header-bar"> |
| 59 |
|
| 60 |
|
| 61 |
<?php |
| 62 |
echo '<img src="' . MLSIMPORT_PLUGIN_URL . '/img/mlsimport-logo.webp" alt="My Plugin Logo" style="max-width:200px;" />'; |
| 63 |
?> |
| 64 |
|
| 65 |
<h1 class="mlsimport-wizard-title"> |
| 66 |
<?php _e('MLSImport Setup Wizard', 'mlsimport'); ?> |
| 67 |
</h1> |
| 68 |
|
| 69 |
<a href="<?php echo esc_url(admin_url('admin.php?page=mlsimport_plugin_options')); ?>" class="mlsimport-wizard-close"> |
| 70 |
<span class="dashicons dashicons-no-alt"></span> |
| 71 |
</a> |
| 72 |
</div> |
| 73 |
|
| 74 |
<div class="mlsimport-wizard-header"> |
| 75 |
<div class="mlsimport-wizard-progress"> |
| 76 |
<div class="mlsimport-wizard-progress-bar"> |
| 77 |
<div class="mlsimport-wizard-progress-bar-inner" style="width: <?php echo esc_attr($progress_percentage); ?>%"></div> |
| 78 |
</div> |
| 79 |
<div class="mlsimport-wizard-steps"> |
| 80 |
<?php foreach ($steps as $step_id => $step) : ?> |
| 81 |
<?php |
| 82 |
$step_index = array_search($step_id, $step_keys); |
| 83 |
$step_class = 'mlsimport-wizard-step'; |
| 84 |
if ($step_index < $current_step_index) { |
| 85 |
$step_class .= ' completed'; |
| 86 |
} elseif ($step_index === $current_step_index) { |
| 87 |
$step_class .= ' active'; |
| 88 |
} |
| 89 |
$step_number = $step_index + 1; |
| 90 |
?> |
| 91 |
<div class="<?php echo esc_attr($step_class); ?>"> |
| 92 |
<div class="mlsimport-wizard-step-number"><?php echo esc_html($step_number); ?></div> |
| 93 |
<div class="mlsimport-wizard-step-title"><?php echo esc_html($step['title']); ?></div> |
| 94 |
</div> |
| 95 |
<?php endforeach; ?> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
</div> |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
<div class="mlsimport-wizard-content mlsimport_2025_card mlsimport-wizard-content-30margin |
| 103 |
<?php |
| 104 |
echo ' mlsimport-wizard-content-'.$current_step; |
| 105 |
?> |
| 106 |
|
| 107 |
"> |
| 108 |
<div class="mlsimport-wizard-content-header"> |
| 109 |
<h2><?php echo esc_html($current_step_data['title']); ?></h2> |
| 110 |
<p class="mlsimport-wizard-description"><?php echo esc_html($current_step_data['description']); ?></p> |
| 111 |
</div> |
| 112 |
|
| 113 |
<div class="mlsimport-wizard-content-body"> |
| 114 |
<form id="mlsimport-wizard-form" method="post" action=""> |
| 115 |
<?php |
| 116 |
// Output nonce field |
| 117 |
wp_nonce_field('mlsimport_onboarding', 'mlsimport_onboarding_nonce'); |
| 118 |
|
| 119 |
// Include the current step template |
| 120 |
mlsimport_render_onboarding_step($current_step); |
| 121 |
?> |
| 122 |
|
| 123 |
<div class="mlsimport-wizard-actions"> |
| 124 |
<?php if ($can_go_back) : ?> |
| 125 |
<a href="<?php echo esc_url($prev_url); ?>" class="button mlsimport_button secondary"> |
| 126 |
<?php _e('Back', 'mlsimport'); ?> |
| 127 |
</a> |
| 128 |
<?php endif; ?> |
| 129 |
|
| 130 |
<?php if ($is_last_step) : ?> |
| 131 |
<button type="submit" class="button button-primary mlsimport-wizard-next mlsimport_button mlsimport-wizard-submit"> |
| 132 |
<?php _e('Complete Setup', 'mlsimport'); ?> |
| 133 |
</button> |
| 134 |
<?php else : ?> |
| 135 |
<button type="submit" class="button button-primary mlsimport-wizard-next mlsimport_button "> |
| 136 |
<?php _e('Continue', 'mlsimport'); ?> |
| 137 |
</button> |
| 138 |
<?php endif; ?> |
| 139 |
|
| 140 |
<input type="hidden" name="mlsimport_onboarding_submit" value="1"> |
| 141 |
<input type="hidden" name="mlsimport_current_step" value="<?php echo esc_attr($current_step); ?>"> |
| 142 |
</div> |
| 143 |
</form> |
| 144 |
</div> |
| 145 |
</div> |
| 146 |
|
| 147 |
<div class="mlsimport-wizard-footer"> |
| 148 |
<div class="mlsimport-wizard-help"> |
| 149 |
<p> |
| 150 |
<?php _e('Need help?', 'mlsimport'); ?> |
| 151 |
<a href="https://mlsimport.com/support" target="_blank"><?php _e('Contact Support', 'mlsimport'); ?></a> |
| 152 |
</p> |
| 153 |
</div> |
| 154 |
<div class="mlsimport-wizard-restart"> |
| 155 |
<a href="<?php echo esc_url(admin_url('admin.php?page=mlsimport-onboarding&restart_wizard=1')); ?>" class=" button mlsimport_button secondary"> |
| 156 |
<?php _e('Restart Setup', 'mlsimport'); ?> |
| 157 |
</a> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
</div> |