| 1 |
<?php |
| 2 |
/** |
| 3 |
* Completed Setup Wizard overview template. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
* |
| 7 |
* @var array<string,mixed> $overview Authorized presentation data. |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
$overview = isset( $overview ) && is_array( $overview ) ? $overview : array(); |
| 15 |
$checkpoint = isset( $overview['checkpoint'] ) && is_array( $overview['checkpoint'] ) ? $overview['checkpoint'] : array(); |
| 16 |
$groups = isset( $overview['groups'] ) && is_array( $overview['groups'] ) ? $overview['groups'] : array(); |
| 17 |
$publishing_allowed = ! empty( $overview['publishing_allowed'] ); |
| 18 |
$publishing_url = isset( $overview['publishing_url'] ) ? (string) $overview['publishing_url'] : ''; |
| 19 |
$expected_revision = isset( $checkpoint['revision'] ) ? absint( $checkpoint['revision'] ) : 0; |
| 20 |
$admin_post_url = isset( $overview['admin_post_url'] ) ? (string) $overview['admin_post_url'] : admin_url( 'admin-post.php' ); |
| 21 |
$notice = isset( $overview['notice'] ) && is_array( $overview['notice'] ) ? $overview['notice'] : array(); |
| 22 |
$published_page_count = isset( $overview['published_page_count'] ) ? absint( $overview['published_page_count'] ) : 0; |
| 23 |
$action_nonce = wp_create_nonce( WPBC_Setup_Wizard_Setup_Overview_Actions::NONCE_ACTION ); |
| 24 |
?> |
| 25 |
|
| 26 |
<div class="wpbc_setup_overview"> |
| 27 |
<?php if ( ! empty( $notice['text'] ) ) : ?> |
| 28 |
<div class="notice notice-<?php echo esc_attr( isset( $notice['type'] ) ? sanitize_html_class( $notice['type'] ) : 'info' ); ?> is-dismissible" role="status"> |
| 29 |
<p><?php echo esc_html( $notice['text'] ); ?></p> |
| 30 |
</div> |
| 31 |
<?php endif; ?> |
| 32 |
|
| 33 |
<section class="wpbc_setup_overview__actions" aria-label="<?php esc_attr_e( 'Setup actions', 'booking' ); ?>"> |
| 34 |
<div class="wpbc_setup_overview__action"> |
| 35 |
<form |
| 36 |
method="post" |
| 37 |
action="<?php echo esc_url( $admin_post_url ); ?>" |
| 38 |
data-wpbc-setup-overview-restart-form |
| 39 |
data-confirm-message="<?php esc_attr_e( 'Start a new setup? This restarts wizard navigation and recommendations, but it does not undo settings already saved in Booking Calendar.', 'booking' ); ?>" |
| 40 |
> |
| 41 |
<input type="hidden" name="action" value="<?php echo esc_attr( WPBC_Setup_Wizard_Setup_Overview_Actions::ACTION_RESTART ); ?>"> |
| 42 |
<input type="hidden" name="expected_revision" value="<?php echo esc_attr( (string) $expected_revision ); ?>"> |
| 43 |
<input type="hidden" name="<?php echo esc_attr( WPBC_Setup_Wizard_Setup_Overview_Actions::NONCE_NAME ); ?>" value="<?php echo esc_attr( $action_nonce ); ?>"> |
| 44 |
<button type="submit" class="button button-primary button-hero wpbc_setup_overview__action_button"> |
| 45 |
<i class="menu_icon icon-1x wpbc_icn_add" aria-hidden="true"></i> |
| 46 |
<span><?php esc_html_e( 'Start a new setup', 'booking' ); ?></span> |
| 47 |
</button> |
| 48 |
</form> |
| 49 |
<p><?php esc_html_e( 'Review the current configuration again from the first step.', 'booking' ); ?></p> |
| 50 |
</div> |
| 51 |
|
| 52 |
<div class="wpbc_setup_overview__action"> |
| 53 |
<button |
| 54 |
type="button" |
| 55 |
class="button button-hero wpbc_setup_overview__action_button" |
| 56 |
data-wpbc-booking-pages-open-dialog="1" |
| 57 |
aria-haspopup="dialog" |
| 58 |
<?php disabled( 0, $published_page_count ); ?> |
| 59 |
> |
| 60 |
<i class="menu_icon icon-1x wpbc_icn_description" aria-hidden="true"></i> |
| 61 |
<span><?php esc_html_e( 'Test your booking pages', 'booking' ); ?></span> |
| 62 |
</button> |
| 63 |
<p> |
| 64 |
<?php |
| 65 |
if ( $published_page_count ) { |
| 66 |
esc_html_e( 'Open published pages and try each booking experience.', 'booking' ); |
| 67 |
} else { |
| 68 |
esc_html_e( 'No validated published booking page was found.', 'booking' ); |
| 69 |
} |
| 70 |
?> |
| 71 |
</p> |
| 72 |
</div> |
| 73 |
|
| 74 |
<div class="wpbc_setup_overview__action"> |
| 75 |
<?php if ( $publishing_allowed && '' !== $publishing_url ) : ?> |
| 76 |
<a href="<?php echo esc_url( $publishing_url ); ?>" class="button button-hero wpbc_setup_overview__action_button"> |
| 77 |
<i class="menu_icon icon-1x wpbc_icn_code" aria-hidden="true"></i> |
| 78 |
<span><?php esc_html_e( 'Publish or integrate', 'booking' ); ?></span> |
| 79 |
</a> |
| 80 |
<p><?php esc_html_e( 'Add your booking form to a page so customers can book.', 'booking' ); ?></p> |
| 81 |
<?php else : ?> |
| 82 |
<button type="button" class="button button-hero wpbc_setup_overview__action_button" disabled> |
| 83 |
<i class="menu_icon icon-1x wpbc_icn_code" aria-hidden="true"></i> |
| 84 |
<span><?php esc_html_e( 'Publish or integrate', 'booking' ); ?></span> |
| 85 |
</button> |
| 86 |
<p><?php esc_html_e( 'Publishing is unavailable in this temporary environment.', 'booking' ); ?></p> |
| 87 |
<?php endif; ?> |
| 88 |
</div> |
| 89 |
</section> |
| 90 |
|
| 91 |
<div class="wpbc_setup_overview__table_wrap" role="region" aria-label="<?php esc_attr_e( 'Current Booking Calendar setup', 'booking' ); ?>" tabindex="0"> |
| 92 |
<table class="wpbc_setup_overview__table"> |
| 93 |
<thead> |
| 94 |
<tr> |
| 95 |
<th scope="col" class="wpbc_setup_overview__number_heading"><?php echo esc_html_x( '#', 'Setup overview group number', 'booking' ); ?></th> |
| 96 |
<th scope="col"><?php esc_html_e( 'Setting', 'booking' ); ?></th> |
| 97 |
<th scope="col"><?php esc_html_e( 'Current choice', 'booking' ); ?></th> |
| 98 |
<th scope="col"><?php esc_html_e( 'Action', 'booking' ); ?></th> |
| 99 |
</tr> |
| 100 |
</thead> |
| 101 |
<tbody> |
| 102 |
<?php foreach ( $groups as $group ) : ?> |
| 103 |
<?php |
| 104 |
$rows = isset( $group['rows'] ) && is_array( $group['rows'] ) ? $group['rows'] : array(); |
| 105 |
$row_count = count( $rows ); |
| 106 |
if ( 0 === $row_count ) { |
| 107 |
continue; |
| 108 |
} |
| 109 |
?> |
| 110 |
<?php foreach ( $rows as $row_index => $row ) : ?> |
| 111 |
<?php |
| 112 |
$row = is_array( $row ) ? $row : array(); |
| 113 |
$action = isset( $row['action'] ) && is_array( $row['action'] ) ? $row['action'] : array(); |
| 114 |
$action_type = isset( $action['type'] ) ? sanitize_key( (string) $action['type'] ) : 'none'; |
| 115 |
$summary_type = isset( $row['summary_type'] ) ? sanitize_html_class( (string) $row['summary_type'] ) : 'default'; |
| 116 |
?> |
| 117 |
<tr> |
| 118 |
<?php if ( 0 === $row_index ) : ?> |
| 119 |
<th scope="rowgroup" rowspan="<?php echo esc_attr( (string) $row_count ); ?>" class="wpbc_setup_overview__group"> |
| 120 |
<div class="wpbc_setup_overview__group_content"> |
| 121 |
<span class="wpbc_setup_overview__group_number" aria-hidden="true"><?php echo esc_html( (string) absint( isset( $group['number'] ) ? $group['number'] : 0 ) ); ?></span> |
| 122 |
<div> |
| 123 |
<strong><?php echo esc_html( isset( $group['title'] ) ? $group['title'] : '' ); ?></strong> |
| 124 |
<p><?php echo esc_html( isset( $group['description'] ) ? $group['description'] : '' ); ?></p> |
| 125 |
</div> |
| 126 |
</div> |
| 127 |
</th> |
| 128 |
<?php endif; ?> |
| 129 |
<th scope="row" class="wpbc_setup_overview__setting"> |
| 130 |
<span class="wpbc_setup_overview__setting_content"> |
| 131 |
<i class="menu_icon icon-1x <?php echo esc_attr( isset( $row['icon'] ) ? $row['icon'] : '' ); ?>" aria-hidden="true"></i> |
| 132 |
<span><?php echo esc_html( isset( $row['label'] ) ? $row['label'] : '' ); ?></span> |
| 133 |
</span> |
| 134 |
</th> |
| 135 |
<td class="wpbc_setup_overview__summary wpbc_setup_overview__summary--<?php echo esc_attr( $summary_type ); ?>"> |
| 136 |
<?php echo esc_html( isset( $row['summary'] ) ? $row['summary'] : '' ); ?> |
| 137 |
</td> |
| 138 |
<td class="wpbc_setup_overview__row_action"> |
| 139 |
<?php if ( 'link' === $action_type && ! empty( $action['url'] ) ) : ?> |
| 140 |
<a href="<?php echo esc_url( $action['url'] ); ?>"><?php echo esc_html( isset( $action['label'] ) ? $action['label'] : '' ); ?></a> |
| 141 |
<?php elseif ( 'wizard_step' === $action_type && ! empty( $action['step_id'] ) ) : ?> |
| 142 |
<form method="post" action="<?php echo esc_url( $admin_post_url ); ?>"> |
| 143 |
<input type="hidden" name="action" value="<?php echo esc_attr( WPBC_Setup_Wizard_Setup_Overview_Actions::ACTION_REOPEN_STEP ); ?>"> |
| 144 |
<input type="hidden" name="target_step_id" value="<?php echo esc_attr( $action['step_id'] ); ?>"> |
| 145 |
<input type="hidden" name="expected_revision" value="<?php echo esc_attr( (string) $expected_revision ); ?>"> |
| 146 |
<input type="hidden" name="<?php echo esc_attr( WPBC_Setup_Wizard_Setup_Overview_Actions::NONCE_NAME ); ?>" value="<?php echo esc_attr( $action_nonce ); ?>"> |
| 147 |
<button type="submit" class="button-link"><?php echo esc_html( isset( $action['label'] ) ? $action['label'] : '' ); ?></button> |
| 148 |
</form> |
| 149 |
<?php else : ?> |
| 150 |
<span aria-hidden="true">—</span><span class="screen-reader-text"><?php esc_html_e( 'No action available', 'booking' ); ?></span> |
| 151 |
<?php endif; ?> |
| 152 |
</td> |
| 153 |
</tr> |
| 154 |
<?php endforeach; ?> |
| 155 |
<?php endforeach; ?> |
| 156 |
</tbody> |
| 157 |
</table> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
|
| 161 |
<?php |
| 162 |
if ( $published_page_count && class_exists( 'WPBC_Setup_Wizard_Booking_Pages' ) ) { |
| 163 |
WPBC_Setup_Wizard_Booking_Pages::render_template(); |
| 164 |
} |
| 165 |
?> |
| 166 |
|