step data). // Get all steps $steps = mlsimport_get_steps(); // Bail out early if there are no steps to render. // Check if steps exist if (empty($steps) || !is_array($steps)) { return; } // Resolve which step is currently being displayed. // Get current step $current_step = mlsimport_get_current_step(); // Derive index/total and the progress bar fill percentage from the step keys. // Get all step keys for progress calculation $step_keys = array_keys($steps); $current_step_index = array_search($current_step, $step_keys); $total_steps = count($steps); $progress_percentage = ($current_step_index / ($total_steps - 1)) * 100; // Data (title/description) for the current step, with a safe fallback. // Get current step data $current_step_data = isset($steps[$current_step]) ? $steps[$current_step] : array( 'title' => __('Unknown Step', 'mlsimport'), 'description' => '', ); // Back button shows only when not on the first step. // Check if we can go back $can_go_back = $current_step_index > 0; // True on the final step (switches the primary button to "Complete Setup"). // Check if we're on the last step $is_last_step = $current_step_index === count($step_keys) - 1; // Compute the next/previous step ids (empty at the ends). // Get next/previous step URLs $next_step = $current_step_index < count($step_keys) - 1 ? $step_keys[$current_step_index + 1] : ''; $prev_step = $current_step_index > 0 ? $step_keys[$current_step_index - 1] : ''; // Build the admin URLs used by the Back/next navigation. $next_url = admin_url('admin.php?page=mlsimport-onboarding&step=' . $next_step); $prev_url = admin_url('admin.php?page=mlsimport-onboarding&step=' . $prev_step); ?>