| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying content of setup wizard. |
| 4 |
* |
| 5 |
* @author ThimPres |
| 6 |
* @package LearnPress/Admin/Views |
| 7 |
* @version 3.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
defined( 'ABSPATH' ) or exit; |
| 11 |
$wizard = LP_Setup_Wizard::instance(); |
| 12 |
|
| 13 |
if ( ! isset( $steps ) ) { |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
$current_step = $wizard->get_current_step(); |
| 18 |
$is_welcome_step = 'welcome' === $current_step; |
| 19 |
$is_finish_step = 'finish' === $current_step; |
| 20 |
$next_url = $is_finish_step ? admin_url( 'index.php' ) : $wizard->get_next_url(); |
| 21 |
$main_class = $is_welcome_step ? 'lp-setup-main--welcome' : 'lp-setup-main--wizard'; |
| 22 |
$wizard_steps = array(); |
| 23 |
|
| 24 |
foreach ( $steps as $step_key => $step_data ) { |
| 25 |
if ( 'welcome' !== $step_key ) { |
| 26 |
$wizard_steps[ $step_key ] = $step_data; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
$wizard_step_keys = array_keys( $wizard_steps ); |
| 31 |
?> |
| 32 |
|
| 33 |
<div id="main" class="<?php echo esc_attr( $main_class ); ?>"> |
| 34 |
<form id="learn-press-setup-form" class="lp-setup-content lp-setup-wizard-form" name="lp-setup" method="post"> |
| 35 |
<?php |
| 36 |
$step = $wizard->get_current_step( false ); |
| 37 |
?> |
| 38 |
<input type="hidden" name="lp-setup-step" |
| 39 |
value="<?php echo esc_attr( $step['slug'] ); ?>"> |
| 40 |
<?php call_user_func( $step['callback'] ); ?> |
| 41 |
<?php if ( ! $wizard->is_last_step() || $is_finish_step ) { ?> |
| 42 |
<?php if ( $is_welcome_step ) { ?> |
| 43 |
<div class="buttons"> |
| 44 |
<button type="button" class="lp-button button button-next button-primary" data-next-url="<?php echo esc_url( $next_url ); ?>"> |
| 45 |
<span class="lp-setup-button__label"><?php echo wp_kses_post( $step['next_button'] ); ?></span> |
| 46 |
</button> |
| 47 |
<a class="button-dismiss-setup" href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>"> |
| 48 |
<?php esc_html_e( 'Dismiss Setup Wizard', 'learnpress' ); ?> |
| 49 |
</a> |
| 50 |
</div> |
| 51 |
<?php } else { ?> |
| 52 |
<div class="lp-setup-footer-bar"> |
| 53 |
<div class="lp-setup-footer-bar__back"> |
| 54 |
<?php if ( ! $is_finish_step && ! ( array_key_exists( 'back_button', $step ) && false === $step['back_button'] ) ) { ?> |
| 55 |
<a class="lp-button button button-prev" href="<?php echo esc_url( $wizard->get_prev_url() ); ?>"> |
| 56 |
<?php echo ! empty( $step['back_button'] ) ? wp_kses_post( $step['back_button'] ) : esc_html__( 'Back', 'learnpress' ); ?> |
| 57 |
</a> |
| 58 |
<?php } ?> |
| 59 |
</div> |
| 60 |
|
| 61 |
<ol class="lp-setup-stepper" aria-label="<?php esc_attr_e( 'Setup progress', 'learnpress' ); ?>"> |
| 62 |
<?php |
| 63 |
$current_position = array_search( $current_step, $wizard_step_keys, true ); |
| 64 |
foreach ( $wizard_steps as $step_key => $step_data ) { |
| 65 |
$step_position = array_search( $step_key, $wizard_step_keys, true ); |
| 66 |
$item_class = 'lp-setup-stepper__item'; |
| 67 |
if ( $step_key === $current_step ) { |
| 68 |
$item_class .= ' is-active'; |
| 69 |
} elseif ( false !== $current_position && $step_position < $current_position ) { |
| 70 |
$item_class .= ' is-complete'; |
| 71 |
} |
| 72 |
?> |
| 73 |
<li class="<?php echo esc_attr( $item_class ); ?>"> |
| 74 |
<span class="lp-setup-stepper__number"> |
| 75 |
<?php if ( false !== strpos( $item_class, 'is-complete' ) ) { ?> |
| 76 |
<span class="lp-icon-check" aria-hidden="true"></span> |
| 77 |
<?php } else { ?> |
| 78 |
<?php echo esc_html( $step_position + 1 ); ?> |
| 79 |
<?php } ?> |
| 80 |
</span> |
| 81 |
<span class="lp-setup-stepper__label"><?php echo esc_html( $step_data['title'] ); ?></span> |
| 82 |
</li> |
| 83 |
<?php } ?> |
| 84 |
</ol> |
| 85 |
|
| 86 |
<div class="lp-setup-footer-bar__controls"> |
| 87 |
<?php if ( $is_finish_step ) { ?> |
| 88 |
<button type="button" class="lp-button button button-next button-primary" data-next-url="<?php echo esc_url( $next_url ); ?>"> |
| 89 |
<span class="lp-setup-button__label"><?php esc_html_e( 'Go to Dashboard', 'learnpress' ); ?></span> |
| 90 |
</button> |
| 91 |
<?php } else { ?> |
| 92 |
<a class="lp-button button-link button-skip-next" href="<?php echo esc_url( $next_url ); ?>"> |
| 93 |
<?php esc_html_e( 'Skip this step', 'learnpress' ); ?> |
| 94 |
</a> |
| 95 |
<button type="button" class="lp-button button button-next button-primary" data-next-url="<?php echo esc_url( $next_url ); ?>"> |
| 96 |
<span class="lp-setup-button__label"><?php echo ! empty( $step['next_button'] ) ? wp_kses_post( $step['next_button'] ) : esc_html__( 'Next', 'learnpress' ); ?></span> |
| 97 |
</button> |
| 98 |
<?php } ?> |
| 99 |
</div> |
| 100 |
</div> |
| 101 |
<?php } ?> |
| 102 |
<?php } ?> |
| 103 |
</form> |
| 104 |
</div> |
| 105 |
|