PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / includes / page-setup-wizard / step-publish-integration / template.php

template.php in Booking Calendar 11.9, at includes/page-setup-wizard/step-publish-integration/template.php

224 lines 14.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Progressive Publish & integrate Setup Wizard page.
4 *
5 * @package Booking Calendar
6 * @var array<string,mixed> $template_context Authorized step context.
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 $step_data = isset( $template_context['step_data'] ) && is_array( $template_context['step_data'] ) ? $template_context['step_data'] : array();
14 $values = isset( $step_data['values'] ) && is_array( $step_data['values'] ) ? $step_data['values'] : array();
15 $destinations = isset( $step_data['destinations'] ) && is_array( $step_data['destinations'] ) ? $step_data['destinations'] : array();
16 $pages = isset( $step_data['pages'] ) && is_array( $step_data['pages'] ) ? $step_data['pages'] : array();
17 $content_options = isset( $step_data['content_options'] ) && is_array( $step_data['content_options'] ) ? $step_data['content_options'] : array();
18 $selected_content = isset( $step_data['selected_content'] ) && is_array( $step_data['selected_content'] ) ? $step_data['selected_content'] : array();
19 $insertion_help = isset( $step_data['insertion_help'] ) && is_array( $step_data['insertion_help'] ) ? $step_data['insertion_help'] : array();
20 $destination_id = isset( $values['publish_destination'] ) ? sanitize_key( (string) $values['publish_destination'] ) : '';
21 $page_title = isset( $values['publish_page_title'] ) ? (string) $values['publish_page_title'] : '';
22 $existing_page_id = isset( $values['publish_existing_page_id'] ) ? absint( $values['publish_existing_page_id'] ) : 0;
23 $content_id = isset( $values['publish_page_content'] ) ? sanitize_key( (string) $values['publish_page_content'] ) : '';
24 $page_url = isset( $step_data['page_url'] ) ? (string) $step_data['page_url'] : '';
25 $home_path = isset( $step_data['home_path'] ) ? (string) $step_data['home_path'] : '/';
26 $has_created_page = ! empty( $step_data['has_created_page'] );
27 $shortcode = isset( $selected_content['shortcode'] ) ? (string) $selected_content['shortcode'] : '';
28 $shortcode_help_url = isset( $selected_content['shortcode_help_url'] ) ? (string) $selected_content['shortcode_help_url'] : '';
29 $shortcode_help_label = isset( $selected_content['shortcode_help_label'] ) ? (string) $selected_content['shortcode_help_label'] : '';
30 $insertion_help_url = isset( $insertion_help['url'] ) ? (string) $insertion_help['url'] : '';
31 $insertion_help_label = isset( $insertion_help['label'] ) ? (string) $insertion_help['label'] : '';
32 ?>
33 <section class="wpbc_setup_wizard__step-content wpbc_setup_wizard__publish-step" aria-labelledby="wpbc-setup-wizard-step-title">
34 <header class="wpbc_setup_wizard__step-heading">
35 <h1 id="wpbc-setup-wizard-step-title"><?php esc_html_e( 'Choose how customers will access booking', 'booking' ); ?></h1>
36 <p class="wpbc_setup_wizard__lead"><?php esc_html_e( 'Choose a destination. Your page or publishing choice is saved when you continue.', 'booking' ); ?></p>
37 </header>
38 <?php
39 $template_context['templates']->render(
40 'settings-hint',
41 array( 'settings_hint' => $template_context['settings_hint'] )
42 );
43 ?>
44
45 <form id="wpbc-setup-wizard-step-form" novalidate>
46 <div class="wpbc_setup_wizard__publish-editor" data-wpbc-publish-integration-editor data-home-path="<?php echo esc_attr( $home_path ); ?>" data-has-created-page="<?php echo esc_attr( $has_created_page ? '1' : '0' ); ?>">
47 <fieldset class="wpbc_setup_wizard__publish-destinations">
48 <legend class="screen-reader-text"><?php esc_html_e( 'Booking access destination', 'booking' ); ?></legend>
49 <?php foreach ( $destinations as $destination ) : ?>
50 <?php
51 $option_id = isset( $destination['id'] ) ? sanitize_key( (string) $destination['id'] ) : '';
52 $option_label = isset( $destination['label'] ) ? (string) $destination['label'] : '';
53 $option_text = isset( $destination['description'] ) ? (string) $destination['description'] : '';
54 $option_icon = isset( $destination['icon'] ) ? sanitize_html_class( (string) $destination['icon'] ) : 'wpbc_icn_description';
55 $option_badge = isset( $destination['badge'] ) ? (string) $destination['badge'] : '';
56 $option_badge_id = '' !== $option_badge ? 'wpbc-publish-destination-badge-' . $option_id : '';
57 $is_enabled = ! empty( $destination['is_enabled'] );
58 $disabled_reason = isset( $destination['disabled_reason'] ) ? (string) $destination['disabled_reason'] : '';
59 $is_selected = $destination_id === $option_id;
60 ?>
61 <div class="wpbc_setup_wizard__publish-destination-option">
62 <span class="wpbc_setup_wizard__publish-destination-badges">
63 <?php if ( '' !== $option_badge ) : ?>
64 <span id="<?php echo esc_attr( $option_badge_id ); ?>" class="wpbc_setup_wizard__publish-badge"><?php echo esc_html( $option_badge ); ?></span>
65 <?php endif; ?>
66 </span>
67 <label class="wpbc_setup_wizard__publish-destination-card<?php echo $is_selected ? ' is-selected' : ''; ?><?php echo $is_enabled ? '' : ' is-disabled'; ?>"<?php echo '' !== $disabled_reason ? ' title="' . esc_attr( $disabled_reason ) . '"' : ''; ?>>
68 <span class="wpbc_setup_wizard__publish-destination-heading">
69 <input
70 type="radio"
71 name="publish_destination"
72 value="<?php echo esc_attr( $option_id ); ?>"
73 required
74 data-wpbc-setup-wizard-field
75 data-wpbc-publish-destination
76 <?php if ( '' !== $option_badge_id ) : ?>
77 aria-describedby="<?php echo esc_attr( $option_badge_id ); ?>"
78 <?php endif; ?>
79 <?php checked( $is_selected ); ?>
80 <?php disabled( ! $is_enabled ); ?>
81 >
82 <i class="menu_icon icon-2x <?php echo esc_attr( $option_icon ); ?>" aria-hidden="true"></i>
83 <strong><?php echo esc_html( $option_label ); ?></strong>
84 </span>
85
86 <span><?php echo esc_html( $option_text ); ?></span>
87 <?php if ( ! $is_enabled && '' !== $disabled_reason ) : ?>
88 <small><?php echo esc_html( $disabled_reason ); ?></small>
89 <?php endif; ?>
90 </label>
91 </div>
92 <?php endforeach; ?>
93 </fieldset>
94 <span class="wpbc_setup_wizard__field-error wpbc_setup_wizard__field-error--group" data-wpbc-setup-wizard-error-for="publish_destination"></span>
95
96 <section class="wpbc_setup_wizard__publish-settings" aria-labelledby="wpbc-publish-settings-title">
97 <header>
98 <h2 id="wpbc-publish-settings-title"><?php esc_html_e( 'Page settings', 'booking' ); ?></h2>
99 <p><?php esc_html_e( 'Set up your booking page details and choose what happens next.', 'booking' ); ?></p>
100 </header>
101
102 <div class="wpbc_setup_wizard__publish-later wpbc_setup_wizard__message wpbc_setup_wizard__message--info" data-wpbc-publish-later-panel <?php echo WPBC_Setup_Wizard_Publish_Integration::DESTINATION_LATER === $destination_id ? '' : 'hidden'; ?>>
103 <i class="menu_icon icon-1x wpbc_icn_schedule" aria-hidden="true"></i>
104 <div>
105 <strong><?php esc_html_e( 'Finish setup without publishing', 'booking' ); ?></strong>
106 <p><?php esc_html_e( 'Your booking configuration is already saved. You can add the booking experience to a WordPress page later.', 'booking' ); ?></p>
107 </div>
108 </div>
109
110 <div class="wpbc_setup_wizard__publish-settings-body" data-wpbc-publish-settings-body <?php echo WPBC_Setup_Wizard_Publish_Integration::DESTINATION_LATER === $destination_id ? 'hidden' : ''; ?>>
111 <div class="wpbc_setup_wizard__publish-fields">
112 <div class="wpbc_setup_wizard__publish-page-fields">
113 <label class="wpbc_setup_wizard__publish-field" data-wpbc-publish-create-field <?php echo WPBC_Setup_Wizard_Publish_Integration::DESTINATION_CREATE_PAGE === $destination_id ? '' : 'hidden'; ?>>
114 <span><?php esc_html_e( 'Page title', 'booking' ); ?></span>
115 <input
116 type="text"
117 name="publish_page_title"
118 value="<?php echo esc_attr( $page_title ); ?>"
119 maxlength="200"
120 data-wpbc-setup-wizard-field
121 data-wpbc-publish-page-title
122 <?php if ( WPBC_Setup_Wizard_Publish_Integration::DESTINATION_CREATE_PAGE === $destination_id ) : ?>
123 required
124 <?php endif; ?>
125 >
126 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="publish_page_title"></span>
127 </label>
128
129 <label class="wpbc_setup_wizard__publish-field" data-wpbc-publish-existing-field <?php echo WPBC_Setup_Wizard_Publish_Integration::DESTINATION_EXISTING_PAGE === $destination_id ? '' : 'hidden'; ?>>
130 <span><?php esc_html_e( 'WordPress page', 'booking' ); ?></span>
131 <select
132 name="publish_existing_page_id"
133 data-wpbc-setup-wizard-field
134 data-wpbc-publish-existing-page
135 <?php if ( WPBC_Setup_Wizard_Publish_Integration::DESTINATION_EXISTING_PAGE === $destination_id ) : ?>
136 required
137 <?php endif; ?>
138 >
139 <option value="0"><?php esc_html_e( 'Choose a page', 'booking' ); ?></option>
140 <?php foreach ( $pages as $page ) : ?>
141 <option value="<?php echo esc_attr( (string) absint( $page['id'] ) ); ?>" data-page-url="<?php echo esc_attr( isset( $page['url'] ) ? (string) $page['url'] : '' ); ?>" <?php selected( $existing_page_id, absint( $page['id'] ) ); ?>><?php echo esc_html( isset( $page['title'] ) ? (string) $page['title'] : '' ); ?></option>
142 <?php endforeach; ?>
143 </select>
144 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="publish_existing_page_id"></span>
145 </label>
146
147 <div class="wpbc_setup_wizard__publish-field wpbc_setup_wizard__publish-url-field" data-wpbc-publish-page-url-field <?php echo in_array( $destination_id, array( WPBC_Setup_Wizard_Publish_Integration::DESTINATION_CREATE_PAGE, WPBC_Setup_Wizard_Publish_Integration::DESTINATION_EXISTING_PAGE ), true ) ? '' : 'hidden'; ?>>
148 <span><?php esc_html_e( 'Page URL', 'booking' ); ?></span>
149 <div>
150 <input type="text" value="<?php echo esc_attr( $page_url ); ?>" readonly data-wpbc-publish-page-url>
151 <button type="button" class="button button-link" data-wpbc-publish-copy="page-url" aria-label="<?php esc_attr_e( 'Copy page URL', 'booking' ); ?>">
152 <i class="menu_icon icon-1x wpbc_icn_content_copy" aria-hidden="true"></i>
153 </button>
154 </div>
155 </div>
156 </div>
157
158 <label class="wpbc_setup_wizard__publish-field wpbc_setup_wizard__publish-content-field">
159 <span><?php esc_html_e( 'Page content', 'booking' ); ?></span>
160 <select
161 name="publish_page_content"
162 data-wpbc-setup-wizard-field
163 data-wpbc-publish-page-content
164 <?php if ( WPBC_Setup_Wizard_Publish_Integration::DESTINATION_LATER !== $destination_id ) : ?>
165 required
166 <?php endif; ?>
167 >
168 <?php foreach ( $content_options as $content_option ) : ?>
169 <option
170 value="<?php echo esc_attr( isset( $content_option['id'] ) ? (string) $content_option['id'] : '' ); ?>"
171 data-content-description="<?php echo esc_attr( isset( $content_option['description'] ) ? (string) $content_option['description'] : '' ); ?>"
172 data-content-shortcode="<?php echo esc_attr( isset( $content_option['shortcode'] ) ? (string) $content_option['shortcode'] : '' ); ?>"
173 data-content-help-url="<?php echo esc_url( isset( $content_option['shortcode_help_url'] ) ? (string) $content_option['shortcode_help_url'] : '' ); ?>"
174 data-content-help-label="<?php echo esc_attr( isset( $content_option['shortcode_help_label'] ) ? (string) $content_option['shortcode_help_label'] : '' ); ?>"
175 <?php selected( $content_id, isset( $content_option['id'] ) ? (string) $content_option['id'] : '' ); ?>
176 ><?php echo esc_html( isset( $content_option['label'] ) ? (string) $content_option['label'] : '' ); ?></option>
177 <?php endforeach; ?>
178 </select>
179 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="publish_page_content"></span>
180 </label>
181 </div>
182
183 <aside class="wpbc_setup_wizard__publish-content-info wpbc_setup_wizard__message wpbc_setup_wizard__message--info" aria-live="polite">
184 <i class="menu_icon icon-1x wpbc_icn_info_outline" aria-hidden="true"></i>
185 <div>
186 <strong data-wpbc-publish-content-title><?php echo esc_html( isset( $selected_content['label'] ) ? (string) $selected_content['label'] : '' ); ?></strong>
187 <p data-wpbc-publish-content-description><?php echo esc_html( isset( $selected_content['description'] ) ? (string) $selected_content['description'] : '' ); ?></p>
188 <p><?php esc_html_e( 'This recommendation follows the customer journey selected earlier. You can choose another supported page content option.', 'booking' ); ?></p>
189 <nav class="wpbc_setup_wizard__publish-content-help" aria-label="<?php esc_attr_e( 'Booking shortcode help', 'booking' ); ?>">
190 <a href="<?php echo esc_url( $shortcode_help_url ); ?>" target="_blank" rel="noopener noreferrer" data-wpbc-publish-shortcode-help <?php echo '' === $shortcode_help_url ? 'hidden' : ''; ?>>
191 <span data-wpbc-publish-shortcode-help-label><?php echo esc_html( $shortcode_help_label ); ?></span>
192 <span class="screen-reader-text"><?php esc_html_e( ' (opens in a new tab)', 'booking' ); ?></span>
193 </a>
194 <?php if ( '' !== $insertion_help_url && '' !== $insertion_help_label ) : ?>
195 <a href="<?php echo esc_url( $insertion_help_url ); ?>" target="_blank" rel="noopener noreferrer">
196 <?php echo esc_html( $insertion_help_label ); ?>
197 <span class="screen-reader-text"><?php esc_html_e( ' (opens in a new tab)', 'booking' ); ?></span>
198 </a>
199 <?php endif; ?>
200 </nav>
201 </div>
202 </aside>
203
204 <div class="wpbc_setup_wizard__publish-shortcode">
205 <label for="wpbc-setup-wizard-publish-shortcode"><?php esc_html_e( 'Shortcode', 'booking' ); ?></label>
206 <div>
207 <input id="wpbc-setup-wizard-publish-shortcode" type="text" value="<?php echo esc_attr( $shortcode ); ?>" readonly data-wpbc-publish-shortcode>
208 <button type="button" class="button button-link" data-wpbc-publish-copy="shortcode">
209 <i class="menu_icon icon-1x wpbc_icn_content_copy" aria-hidden="true"></i>
210 <span><?php esc_html_e( 'Copy', 'booking' ); ?></span>
211 </button>
212 </div>
213 </div>
214 </div>
215
216 <div class="wpbc_setup_wizard__publish-notice wpbc_setup_wizard__message wpbc_setup_wizard__message--warning" data-wpbc-publish-notice>
217 <i class="menu_icon icon-1x wpbc_icn_info_outline" aria-hidden="true"></i>
218 <p data-wpbc-publish-notice-text><?php esc_html_e( 'Save creates this WordPress page now. Repeating the save updates the same Setup Wizard page instead of creating a duplicate.', 'booking' ); ?></p>
219 </div>
220 </section>
221 </div>
222 </form>
223 </section>
224