PluginProbe
Booking Calendar / 11.7
Booking Calendar v11.7
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 10.11 10.11.2 10.11.3 10.11.4 All 201 releases
booking / includes / page-setup / setup_templates.php

setup_templates.php in Booking Calendar 11.7, at includes/page-setup/setup_templates.php

477 lines 19.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @description Templates for Setup pages
4 * @category Setup Templates
5 * @author wpdevelop
6 *
7 * @web-site http://oplugins.com/
8 * @email info@oplugins.com
9 *
10 * @modified 2024-08-27
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 class WPBC_AJX__Setup_Wizard__Templates {
17
18 // <editor-fold defaultstate="collapsed" desc=" /// JS | CSS files | Tpl loading /// " >
19
20 /**
21 * Define HOOKs for loading CSS and JavaScript files
22 */
23 public function init_load_css_js_tpl() {
24
25 // Load only at specific Page
26 if ( wpbc_is_setup_wizard_page() ) {
27
28 add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 );
29 add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 );
30
31 add_action( 'wpbc_hook_settings_page_footer', array( $this, 'hook__load_templates_at_footer' ) );
32 }
33 }
34
35
36 /** JS */
37 public function js_load_files( $where_to_load ) {
38
39 $in_footer = true;
40
41 if ( wpbc_is_setup_wizard_page() ){
42
43 wp_enqueue_script( 'wpbc_all', wpbc_plugin_url( '/_dist/all/_out/wpbc_all.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
44 wp_enqueue_script( 'wpbc-main-client', wpbc_plugin_url( '/js/client.js' ), array( 'wpbc-datepick' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
45 wp_enqueue_script( 'wpbc-times', wpbc_plugin_url( '/js/wpbc_times.js' ), array( 'wpbc-main-client' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
46
47 wp_enqueue_script( 'wpbc-settings_obj', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/settings_obj.js', array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer );
48 wp_enqueue_script( 'wpbc-setup_wizard_obj', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/setup_obj.js', array( 'wpbc-settings_obj' ), WP_BK_VERSION_NUM, $in_footer );
49 wp_enqueue_script( 'wpbc-setup_wizard_show', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/setup_show.js', array( 'wpbc-setup_wizard_obj' ), WP_BK_VERSION_NUM, $in_footer );
50 wp_enqueue_script( 'wpbc-setup_wizard_ajax', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/setup_ajax.js', array( 'wpbc-setup_wizard_obj' ), WP_BK_VERSION_NUM, $in_footer );
51
52 wp_enqueue_script(
53 'wpbc-availability-timeslots-page',
54 wpbc_plugin_url( '/includes/page-availability-timeslots/_out/availability_timeslots_page.js' ),
55 array( 'jquery', 'wpbc_all', 'wpbc-datepick' ),
56 WP_BK_VERSION_NUM,
57 array( 'in_footer' => WPBC_JS_IN_FOOTER )
58 );
59
60 wp_localize_script(
61 'wpbc-availability-timeslots-page',
62 'wpbc_availability_timeslots_page',
63 array(
64 'ajax_url' => admin_url( 'admin-ajax.php' ),
65 'nonce' => wp_create_nonce( 'wpbc_availability_timeslots_ajax_nonce' ),
66 'i18n' => array(
67 'select_slots_first' => __( 'Select one or more time ranges first.', 'booking' ),
68 'block_success' => __( 'Selected time ranges have been blocked.', 'booking' ),
69 'unblock_success' => __( 'Selected time ranges have been unblocked.', 'booking' ),
70 'save_error' => __( 'Unable to save time-slot availability.', 'booking' ),
71 'loading' => __( 'Loading', 'booking' ),
72 'open_booking' => __( 'Open booking in Booking Listing', 'booking' ),
73 'open_availability_rule' => __( 'Open availability settings', 'booking' ),
74 'select_one_slot_for_booking' => __( 'Select one time range on one date first.', 'booking' ),
75 'add_booking_modal_missing' => __( 'Add Booking popup is not available on this page.', 'booking' ),
76 'saving' => __( 'Saving', 'booking' ),
77 ),
78 )
79 );
80 }
81 }
82
83
84 /** CSS */
85 public function enqueue_css_files( $where_to_load ) {
86
87 if ( wpbc_is_setup_wizard_page() ){
88
89 wp_enqueue_style( 'wpbc-setup_wizard_page', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/setup_page.css', array(), WP_BK_VERSION_NUM );
90 wp_enqueue_style( 'wpbc-availability-general-page', wpbc_plugin_url( '/includes/page-availability-general/_out/availability_general_page.css' ), array( 'wpbc-calendar', 'wpbc-all-admin' ), WP_BK_VERSION_NUM );
91 wp_enqueue_style( 'wpbc-availability-timeslots-page', wpbc_plugin_url( '/includes/page-availability-timeslots/_out/availability_timeslots_page.css' ), array( 'wpbc-calendar', 'wpbc-all-admin' ), WP_BK_VERSION_NUM );
92 }
93 }
94
95 // </editor-fold>
96
97
98 // <editor-fold defaultstate="collapsed" desc=" /// Templates /// " >
99
100
101 /**
102 * Load Templates at footer of page
103 *
104 * @param $page string
105 */
106 public function hook__load_templates_at_footer( $page ){
107
108 // Hook from ../includes/page-setup/setup__page.php
109 if ( 'wpbc-ajx_booking_setup_wizard' === $page ) {
110
111 $this->wpbc_template__stp_wiz__main_content();
112
113 wpbc_stp_wiz__template__welcome();
114 wpbc_stp_wiz__template__general_info();
115 wpbc_stp_wiz__template__date_time_formats();
116 wpbc_stp_wiz__template__bookings_types();
117
118 $this->wpbc_template__stp_wiz__left_navigation();
119 $this->wpbc_template__stp_wiz__left_navigation_item();
120
121 $this->wpbc_template__timeline_steps();
122 $this->wpbc_template__timeline_steps_icons();
123
124 $this->wpbc_template__stp_wiz__footer_buttons();
125 }
126 }
127
128
129 // =============================================================================================================
130 // == Templates ==
131 // =============================================================================================================
132 /**
133 * Template - Page Container
134 *
135 * Help Tips:
136 *
137 * <script type="text/html" id="tmpl-template_name_a">
138 * Escaped: {{data.test_key}}
139 * HTML: {{{data.test_key}}}
140 * JS: <# if (true) { alert( 1 ); } #>
141 * </script>
142 *
143 * var template__var = wp.template( 'template_name_a' );
144 *
145 * jQuery( '.content' ).html( template__var( { 'test_key' => '<strong>Data</strong>' } ) );
146 *
147 * @return void
148 */
149 private function wpbc_template__stp_wiz__main_content() {
150 ?><script type="text/html" id="tmpl-wpbc_template__stp_wiz__main_content">
151 <#
152 var wpbc_template__timeline_steps = wp.template( 'wpbc_template__timeline_steps' );
153
154 jQuery( '.wpbc__container_place__steps_for_timeline' ).html( wpbc_template__timeline_steps( data ) );
155 #>
156 <div class="wpbc__container_place__steps_for_timeline">{{{ wpbc_template__timeline_steps( data ) }}}</div>
157 <div class="wpbc_setup_wizard_page__container wpbc_ajx_page__container">
158
159 <# if ( false !== data.steps[ data.current_step ][ 'show_section_left' ] ) { #>
160
161 <div class="wpbc_ajx_page__section wpbc_setup_wizard_page__section_left wpbc_ajx_page__section_left">
162 <# var wpbc_template__stp_wiz__left_navigation = wp.template( 'wpbc_template__stp_wiz__left_navigation' ); #>{{{
163
164 wpbc_template__stp_wiz__left_navigation({
165 'left_navigation' : data.left_navigation,
166 'ajx_cleaned_params': data.ajx_cleaned_params
167 })
168 }}}
169 </div>
170
171 <# } #>
172
173 <div class="wpbc_ajx_page__section wpbc_setup_wizard_page__section_main wpbc_ajx_page__section_main">
174 <?php if(0){ ?><script><?php } echo '<#'; ?>
175
176 var template__main_section;
177
178 switch ( data.current_step ) {
179
180 case 'welcome':
181 template__main_section = wp.template( 'wpbc_stp_wiz__template__welcome' );
182 break;
183
184 case 'general_info':
185 template__main_section = wp.template( 'wpbc_stp_wiz__template__general_info' );
186 break;
187
188 case 'date_time_formats':
189 template__main_section = wp.template( 'wpbc_stp_wiz__template__date_time_formats' );
190 break;
191
192 case 'bookings_types':
193 template__main_section = wp.template( 'wpbc_stp_wiz__template__bookings_types' );
194 break;
195
196 default:
197 // Default
198 template__main_section = wp.template( 'wpbc_stp_wiz__template__general_info' );
199 }
200
201 <?php if(0){ ?></script><?php } echo '#>'; ?>
202 {{{
203 template__main_section( data )
204 }}}
205 </div>
206
207 <# if ( false !== data.steps[ data.current_step ][ 'show_section_right' ] ) { #>
208
209 <div class="wpbc_ajx_page__section wpbc_setup_wizard_page__section_right wpbc_ajx_page__section_right">
210 <?php $this->test_right_widget(); ?>
211 </div>
212 <# } #>
213
214 <#
215 var wpbc_template__stp_wiz__footer_buttons = wp.template( 'wpbc_template__stp_wiz__footer_buttons' );
216 #>
217 <div class="wpbc_ajx_page__section wpbc_setup_wizard_page__section_footer wpbc_ajx_page__section_footer">
218 <div class="wpbc__container_place__footer_buttons wpbc_container wpbc_form wpbc_container_booking_form">{{{
219 wpbc_template__stp_wiz__footer_buttons( data )
220 }}}</div>
221 </div>
222 </div>
223 </script><?php
224 }
225
226
227 // -------------------------------------------------------------------------------------------------------------
228 // == Timeline Steps - Line with Checked Dots ==
229 // -------------------------------------------------------------------------------------------------------------
230 private function wpbc_template__timeline_steps(){
231
232 ?><script type="text/html" id="tmpl-wpbc_template__timeline_steps">
233 <# var wpbc_template__timeline_steps_icons = wp.template( 'wpbc_template__timeline_steps_icons' ); #>
234 <div class="wpbc_steps_for_timeline_container">
235 <div class="wpbc_steps_for_timeline">
236 <#
237
238 var steps_arr = data.steps || {};
239 var current_step = data.current_step || '';
240 var steps_keys = _.keys( steps_arr );
241 var steps_count = steps_keys.length;
242 var actual_step_number = 1;
243
244 _.each( steps_keys, function( step_key, step_index ) {
245 if ( step_key === current_step ) {
246 actual_step_number = step_index + 1;
247 return false;
248 }
249 } );
250
251 var css_class_for_step = '';
252 var css_class_for_line = '';
253 var is_line_exist = false;
254
255 for ( var i = 1; i <= steps_count ; i++ ) {
256
257 is_line_exist = ( i > 1 );
258
259 if ( actual_step_number > i ) {
260 css_class_for_step = ' wpbc_steps_for_timeline_step_completed';
261 css_class_for_line = 'wpbc_steps_for_timeline_line_active';
262 } else if ( actual_step_number == i ) {
263 css_class_for_step = ' wpbc_steps_for_timeline_step_active';
264 css_class_for_line = 'wpbc_steps_for_timeline_line_active';
265 } else {
266 css_class_for_step = '';
267 css_class_for_line = '';
268 }
269
270
271 if ( is_line_exist ) { #>
272 <div class="wpbc_steps_for_timeline_step_line {{css_class_for_line}}"></div>
273 <# } #>
274 <div class="wpbc_steps_for_timeline_step {{css_class_for_step}}">
275 {{{ wpbc_template__timeline_steps_icons({ }) }}}
276 </div>
277 <# } #>
278 </div>
279 </div>
280 </script><?php
281 }
282
283 /**
284 * Show template for steps timeline icons
285 *
286 * @return void
287 */
288 private function wpbc_template__timeline_steps_icons() {
289
290 ?>
291 <script type="text/html" id="tmpl-wpbc_template__timeline_steps_icons">
292 <?php
293 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
294 echo wpbc_ui__steps_timeline__get_icons();
295 ?>
296 </script>
297 <?php
298 }
299
300
301 // -------------------------------------------------------------------------------------------------------------
302 // == Footer Action Buttons ==
303 // -------------------------------------------------------------------------------------------------------------
304 private function wpbc_template__stp_wiz__footer_buttons(){
305
306 ?><script type="text/html" id="tmpl-wpbc_template__stp_wiz__footer_buttons">
307 <#
308 var currentStep = data.current_step || '';
309 var currentStepData = ( data.steps && data.steps[ currentStep ] ) ? data.steps[ currentStep ] : {};
310 var priorStep = currentStepData.prior || '';
311 var nextStep = currentStepData.next || '';
312 var doAction = currentStepData.do_action || 'none';
313 var priorTitle = currentStepData.prior_title || '<?php echo esc_js( __( 'Go Back', 'booking' ) ); ?>';
314 var nextTitle = currentStepData.next_title || '<?php echo esc_js( __( 'Save and Continue', 'booking' ) ); ?>';
315 #>
316 <div class="wpbc__form__div">
317 <hr>
318 <div class="wpbc__row wpbc__row__btn_prior_next wpbc_setup_wizard_navigation_row">
319 <div class="wpbc__field wpbc_setup_wizard_navigation_links">
320 <p class="wpbc_exit_link_small">
321 <a href="javascript:void(0)"
322 onclick=" wpbc_ajx__setup_wizard_page__send_request_with_params( { 'do_action': 'skip_wizard' } ); "
323 title="<?php esc_attr_e('Exit and skip the setup wizard','booking'); ?>"
324 ><?php esc_html_e('Exit and skip the setup wizard','booking'); ?></a>
325 <a href="javascript:void(0)" class="wpbc_button_danger"
326 onclick=" wpbc_ajx__setup_wizard_page__send_request_with_params( { 'do_action': 'make_reset' } ); "
327 title="<?php esc_attr_e('Start Setup from Beginning','booking'); ?>"
328 ><?php esc_html_e('Reset Wizard','booking'); ?></a>
329 </p>
330 </div>
331 <div class="wpbc__field wpbc_setup_wizard_navigation_actions">
332 <# if ( '' != priorStep ) { #>
333 <a class="button button-secondary" style="margin-left:auto;margin-right:10px;" tabindex="0"
334 id="btn__toolbar__buttons_prior"
335 onclick=" wpbc_ajx__setup_wizard_page__send_request_with_params( {
336 'current_step': '{{priorStep}}',
337 'do_action': 'none',
338 'ui_clicked_element_id': 'btn__toolbar__buttons_prior'
339 } );
340 wpbc_button_enable_loading_icon( this );
341 wpbc_admin_show_message_processing( '' );" ><i class="menu_icon icon-1x wpbc_icn_arrow_back_ios"></i><span>&nbsp;&nbsp;&nbsp;{{priorTitle}}</span></a>
342
343 <# } else { #>
344 <span style="margin-left:auto;"></span>
345 <# } #>
346 <a class="button button-primary" tabindex="0"
347 id="btn__toolbar__buttons_next"
348 onclick=" wpbc_ajx__setup_wizard_page__send_request_with_params( {
349 'current_step': '{{nextStep}}',
350 'do_action': '{{doAction}}',
351 'ui_clicked_element_id': 'btn__toolbar__buttons_next'
352 ,'step_data': ( 'function' === typeof window.wpbc_setup_wizard_get_step_data ) ? window.wpbc_setup_wizard_get_step_data( '{{currentStep}}' ) : {}
353 } );
354 wpbc_button_enable_loading_icon( this );
355 wpbc_admin_show_message_processing( '' );" ><span>{{nextTitle}}&nbsp;&nbsp;&nbsp;</span><i class="menu_icon icon-1x wpbc_icn_arrow_forward_ios"></i></a>
356 </div>
357 </div>
358 </div>
359 </script><?php
360 }
361
362
363
364 // -------------------------------------------------------------------------------------------------------------
365 // == Left Navigation ==
366 // -------------------------------------------------------------------------------------------------------------
367 /**
368 * Template - Left Navigation
369 *
370 * Help Tips:
371 *
372 * <script type="text/html" id="tmpl-template_name_a">
373 * Escaped: {{data.test_key}}
374 * HTML: {{{data.test_key}}}
375 * JS: <# if (true) { alert( 1 ); } #>
376 * </script>
377 *
378 * var template__var = wp.template( 'template_name_a' );
379 *
380 * jQuery( '.content' ).html( template__var( { 'test_key' => '<strong>Data</strong>' } ) );
381 *
382 * @return void
383 */
384 private function wpbc_template__stp_wiz__left_navigation() {
385 ?><script type="text/html" id="tmpl-wpbc_template__stp_wiz__left_navigation">
386 <div class="wpbc_navigation_menu_left">
387 <#
388 var wpbc_template__stp_wiz__left_navigation_item = wp.template( 'wpbc_template__stp_wiz__left_navigation_item' );
389 _.each( data.left_navigation, function ( p_val, p_id, p_data_arr ){
390 if ( undefined === p_val.a_style){ p_val.a_style = ''; }
391 if ( undefined === p_val.style){ p_val.style = ''; }
392 #>{{{
393 wpbc_template__stp_wiz__left_navigation_item({
394 'id' : p_id,
395 'data_arr': p_val
396 })
397 }}}
398 <# } ); #>
399 </div>
400 </script><?php
401 }
402
403
404 /**
405 * Template - Left Navigation Item
406 *
407 * Help Tips:
408 *
409 * <script type="text/html" id="tmpl-template_name_a">
410 * Escaped: {{data.test_key}}
411 * HTML: {{{data.test_key}}}
412 * JS: <# if (true) { alert( 1 ); } #>
413 * </script>
414 *
415 * var template__var = wp.template( 'template_name_a' );
416 *
417 * jQuery( '.content' ).html( template__var( { 'test_key' => '<strong>Data</strong>' } ) );
418 *
419 * @return void
420 */
421 private function wpbc_template__stp_wiz__left_navigation_item() {
422 ?><script type="text/html" id="tmpl-wpbc_template__stp_wiz__left_navigation_item">
423 <div id="{{data.id}}"
424 class="wpbc_navigation_menu_left_item {{data.data_arr.class}}" style="{{data.data_arr.style}}">
425 <div class="wpbc_navigation_menu_left_item_container">
426 <a class="wpbc_navigation_menu_left_item_a" style="{{data.data_arr.a_style}}" onclick="javascript:{{{data.data_arr.action}}}" href="javascript:void(0);">
427 <i class="wpbc_navigation_menu_left_item_icon menu_icon icon-1x {{data.data_arr.icon}}"></i>
428 <div class="wpbc_navigation_menu_left_item_text">{{{data.data_arr.title}}}</div>
429 </a>
430 <# if ( undefined != data.data_arr.right_icon ) { #>
431 <a class="wpbc_navigation_menu_left_item_icon_right" onclick="javascript:{{{data.data_arr.right_icon.action}}}" href="javascript:void(0);"
432 ><i class="menu_icon icon-1x {{data.data_arr.right_icon.icon}}"></i>
433 <# if ( undefined != data.data_arr.right_icon.text ) { #>
434 <div class="wpbc_navigation_menu_left_small_text_right">{{{data.data_arr.right_icon.text}}}</div>
435 <# } #>
436 </a>
437 <# } #>
438 </div>
439 </div>
440 </script><?php
441 }
442
443
444
445 // TODO: Update this
446 private function test_right_widget(){
447 ?>
448 <div class="wpbc_widgets">
449 <div class="wpbc_widget wpbc_widget_change_calendar_skin">
450 <div class="wpbc_widget_header">
451 <span class="wpbc_widget_header_text">Calendar Skin</span>
452 <a href="/" class="wpbc_widget_header_settings_link"><i class="menu_icon icon-1x wpbc_icn_settings"></i></a>
453 </div>
454 <div class="wpbc_widget_content wpbc_ajx_toolbar" style="margin:0 0 20px;">
455 <div class="ui_container">
456 <div class="ui_group ui_group__change_calendar_skin">
457 </div>
458 </div>
459 </div>
460 </div>
461 </div>
462 <?php
463 }
464
465 // </editor-fold>
466
467 }
468
469
470 /**
471 * Just for loading CSS and JavaScript files
472 */
473 if ( true ) {
474 $wpbc_setup_wizard_page_loading = new WPBC_AJX__Setup_Wizard__Templates;
475 $wpbc_setup_wizard_page_loading->init_load_css_js_tpl();
476 }
477