PluginProbe
Booking Calendar / 11.3
Booking Calendar v11.3
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 10.11 All 204 releases
booking / includes / ui_modal__shortcodes / sh_tpl_booking_import.php

sh_tpl_booking_import.php in Booking Calendar 11.3, at includes/ui_modal__shortcodes/sh_tpl_booking_import.php

438 lines 19.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar Shortcodes Config
5 * @subpackage Shortcodes Content - Shortcodes booking import (for Booking Manager plugin)
6 * @category Shortcodes
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2024-03-08
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // FixIn: 9.9.0.15.
16
17
18
19 // =====================================================================================================================
20 // Shortcodes such as: [bookingimport]
21 // =====================================================================================================================
22
23 /**
24 * Content of PopUp - for shortcode [bookingsearch]
25 *
26 * @return void
27 */
28 function wpbc_shortcode_config__content__booking_ics_import() {
29
30 $shortcode_name = 'booking_import_ics';
31
32 ?><div id="wpbc_sc_container__shortcode_<?php echo esc_attr( $shortcode_name ); ?>" class="wpbc_sc_container__shortcode wpbc_sc_container__shortcode_<?php echo esc_attr( $shortcode_name ); ?>"><?php
33
34 wpbc_shortcode_config__booking_ics_import__top_tabs();
35
36 // 'General' --------------------------------------------------------------------------------------------------
37 ?><div class="wpbc_sc_container__shortcode_section wpbc_sc_container__shortcode_section__general">
38 <table class="form-table"><tbody><?php
39
40 //URL
41 wpbc_shortcode_config_fields__booking_ics_import__url($shortcode_name . '_wpbc_url', $shortcode_name );
42
43 // Booking Resource
44 wpbc_shortcode_config_fields__select_resource( $shortcode_name . '_wpbc_resource_id', $shortcode_name );
45
46 // From
47 wpbc_shortcode_config_fields__booking_ics_import__from_until( $shortcode_name . '_from', $shortcode_name );
48
49 // Until
50 wpbc_shortcode_config_fields__booking_ics_import__from_until( $shortcode_name . '_until', $shortcode_name
51 , array(
52 'options' => array(
53 'now' => __( 'Now', 'booking' )
54 , 'today' => __( '00:00 Today', 'booking' )
55 , 'week' => __( 'End of current week', 'booking' )
56 , 'month-start' => __( 'Start of current month', 'booking' )
57 , 'month-end' => __( 'End of current month', 'booking' )
58 , 'year-end' => __( 'End of current year', 'booking' )
59 , 'any' => __( 'The end of time', 'booking' )
60 , 'date' => __( 'Specific date / time', 'booking' )
61 )
62 , 'value' => 'any'
63 , 'title' => __('Until', 'booking')
64 )
65 );
66
67 ?></tbody></table>
68 </div><?php
69
70 // 'Advanced' -----------------------------------------------------------------------------------------------
71 ?><div class="wpbc_sc_container__shortcode_section wpbc_sc_container__shortcode_section__other"><?php
72 ?><table class="form-table"><tbody><?php
73
74 wpbc_shortcode_config_fields__booking_ics_import__conditions_import( $shortcode_name . '_conditions_import', $shortcode_name );
75
76 wpbc_shortcode_config_fields__booking_ics_import__conditions_events( $shortcode_name . '_conditions_events', $shortcode_name );
77
78 wpbc_shortcode_config_fields__booking_ics_import__conditions_max_num( $shortcode_name . '_conditions_max_num', $shortcode_name );
79
80 wpbc_shortcode_config_fields__booking_ics_import__silence( $shortcode_name . '_silence', $shortcode_name );
81 ?></tbody></table><?php
82 ?></div><?php
83
84
85 ?>
86 <div class="wpbc_shortcode_config_content_toolbar__next_prior">
87 <a href="javascript:void(0)" onclick="javascript:wpbc_shortcode_config_content_toolbar__next_prior(this,'prior');" class="button">
88 <span class="in-button-text">&lsaquo;</span>
89 </a>
90 <a href="javascript:void(0)" onclick="javascript:wpbc_shortcode_config_content_toolbar__next_prior(this,'next');" class="button">
91 <span class="in-button-text">&rsaquo;</span>
92 </a>
93 </div>
94 <?php
95
96 ?></div><?php
97
98 wpbc_clear_div();
99 }
100
101
102 /**
103 * Top Tabs for shortcode [booking ...]
104 * @return void
105 */
106 function wpbc_shortcode_config__booking_ics_import__top_tabs(){
107
108 $shortcode_name = 'booking_import_ics';
109
110 wpbc_bs_toolbar_tabs_html_container_start();
111
112 $js = "jQuery(this).parents( '.wpbc_sc_container__shortcode' ).find( '.nav-tab' ).removeClass('nav-tab-active');"
113 . "jQuery(this).addClass('nav-tab-active');"
114 . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
115 . "jQuery('.nav-tab-active i').addClass('icon-white');"
116 . "jQuery('.wpbc_sc_container__shortcode_" . $shortcode_name . " .wpbc_sc_container__shortcode_section').hide();";
117
118 wpbc_bs_display_tab( array(
119 'title' => __('Import Events (.ics feed)', 'booking')
120 , 'text_css' => 'line-height: 18px;vertical-align: text-top;'
121 // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
122 , 'onclick' => $js . "jQuery('.wpbc_sc_container__shortcode_" . $shortcode_name . " .wpbc_sc_container__shortcode_section__general').show();"
123 , 'font_icon' => 'menu_icon icon-1x wpbc-bi-box-arrow-in-down-right'
124 , 'default' => true
125 ) );
126 wpbc_bs_display_tab( array(
127 'title' => __('Advanced', 'booking')
128 // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
129 , 'onclick' => $js . "jQuery('.wpbc_sc_container__shortcode_" . $shortcode_name . " .wpbc_sc_container__shortcode_section__other').show();"
130 , 'font_icon' => 'wpbc_icn_tune'
131 , 'default' => false
132
133 ) );
134
135 wpbc_bs_toolbar_tabs_html_container_end();
136 }
137
138
139
140 // =====================================================================================================================
141 // Fields
142 // =====================================================================================================================
143
144 /**
145 * Shortcode Field: Header in search results: '{searchresults} Result(s) Found'
146 *
147 * @param $id
148 * @param $group_key
149 *
150 * @return void
151 */
152 function wpbc_shortcode_config_fields__booking_ics_import__url ($id , $group_key ){
153
154 WPBC_Settings_API::field_text_row_static( $id
155 , array(
156 'type' => 'text'
157 , 'placeholder' => __( 'Example', 'booking' ). ': ' . 'https://calendar.google.com/calendar/ical/CALENDAR_ID/public/basic.ics'
158 , 'title' => __( 'URL to .ICS Feed', 'booking' ) //URL to .ICS Feed
159 , 'description' => sprintf( __( 'Enter the url of .ics feed or file.', 'booking' ) , '<code>{searchresults}</code>' )
160 , 'description_tag' => 'span'
161 , 'label' => ''
162 , 'class' => ''
163 , 'css' => 'width:99%;'
164 , 'group' => $group_key
165 , 'tr_class' => $group_key . '_standard_section '
166 , 'only_field' => false
167 , 'attr' => array()
168 , 'value' => ''
169 )
170 );
171
172 }
173
174 /**
175 * Shortcode Fields: "From" | "Until"
176 *
177 * @param $id
178 * @param $group_key
179 *
180 * @return void
181 */
182 function wpbc_shortcode_config_fields__booking_ics_import__from_until( $id , $group_key , $options = array() ){
183
184 $defaults = array(
185 'options' => array(
186 'now' => __( 'Now', 'booking' )
187 , 'today' => __( '00:00 Today', 'booking' )
188 , 'week' => __( 'Start of current week', 'booking' )
189 , 'month-start' => __( 'Start of current month', 'booking' )
190 , 'month-end' => __( 'End of current month', 'booking' )
191 , 'year-start' => __( 'Start of current year', 'booking' )
192 , 'any' => __( 'The start of time', 'booking' )
193 , 'date' => __( 'Specific date / time', 'booking' )
194 )
195 , 'value' => 'today'
196 , 'title' => __('From', 'booking')
197 );
198 $options = wp_parse_args( $options, $defaults );
199
200 ?><tr valign="top" class="<?php echo esc_attr( $group_key . '_standard_section' ); ?> wpbc_sub_settings_grayed0 <?php echo esc_attr( $id ); ?>_wpbc_sc__from_to">
201 <th scope="row" style="vertical-align: middle;">
202 <label for="<?php echo esc_attr( $id . '' ); ?>" class=""><?php echo wp_kses_post( $options['title'] ); ?></label>
203 </th>
204 <td class=""><fieldset><?php
205
206 WPBC_Settings_API::field_select_row_static( $id
207 , array(
208 'type' => 'select'
209 , 'title' => $options['title']
210 , 'description' => ''
211 , 'description_tag' => 'span'
212 , 'label' => ''
213 , 'multiple' => false
214 , 'group' => $group_key
215 , 'tr_class' => $group_key . '_standard_section '
216 , 'class' => ''
217 , 'css' => 'margin-right:10px;'
218 , 'only_field' => true
219 , 'attr' => array()
220 , 'value' => $options['value']
221 , 'options' => $options['options']
222 )
223 );
224
225 ?><label for="<?php echo esc_attr( $id . '_offset' ); ?>" class="<?php echo esc_attr( $id . '_offset_label' ); ?>" style="font-weight:400;padding: 0 8px 0 12px;"><?php
226 echo esc_html__( 'Offset', 'booking' );
227 ?></label>
228 <label for="<?php echo esc_attr( $id . '_offset' ); ?>" class="<?php echo esc_attr( $id . '_date_label' ); ?>" style="font-weight:400;padding: 0 8px 0 12px;display:none;"><?php
229 echo esc_html__( 'Date', 'booking' );
230 ?></label><?php
231
232 WPBC_Settings_API::field_text_row_static( $id . '_offset'
233 , array(
234 'type' => 'text'
235 , 'title' => __('Offset', 'booking' )
236 , 'placeholder' => ''
237 , 'description' => ''
238 , 'description_tag' => 'span'
239 , 'group' => $group_key
240 , 'tr_class' => $group_key . '_standard_section '
241 , 'class' => ''
242 , 'css' => 'width:7em;'
243 , 'only_field' => true
244 , 'attr' => array()
245 , 'value' => ''
246 )
247 );
248 WPBC_Settings_API::field_select_row_static( $id . '_offset_type'
249 , array(
250 'type' => 'select'
251 , 'title' => ''
252 , 'description' => ''
253 , 'description_tag' => 'span'
254 , 'label' => ''
255 , 'multiple' => false
256 , 'group' => $group_key
257 , 'tr_class' => $group_key . '_standard_section '
258 , 'class' => $id . '_offset_label'
259 , 'css' => 'width:6em;'
260 , 'only_field' => true
261 , 'attr' => array()
262 , 'value' => 'day',
263 'options' => array(
264 'day' => __( 'days', 'booking' ),
265 'hour' => __( 'hours', 'booking' ),
266 'minute' => __( 'minutes', 'booking' ),
267 'second' => __( 'seconds', 'booking' )
268 )
269 )
270 );
271 ?><span class="description <?php echo esc_attr( $id . '_offset_label' ); ?>" style="flex0:100%;"> <?php esc_html_e( 'You can specify an optional offset from you chosen start point. The offset can be negative.', 'booking' ); ?></span>
272 <span class="description <?php echo esc_attr( $id . '_date_label' ); ?>" style="flex0:100%;display:none;">
273 <em><?php
274 /* translators: 1: ... */
275 echo wp_kses_post( sprintf( __( 'Type your date in format %1$s. Example: %2$s', 'booking' ), 'Y-m-d', gmdate( 'Y-m-d', strtotime( '+7 days' ) ) ) ); ?></em>
276 </span><?php
277
278 // Show or hide some UI elements, depend on from selection of "From" options.
279 ?><script type="text/javascript">
280 jQuery(document).ready(function(){
281 jQuery( '#<?php echo esc_attr( $id ); ?>' ).on( 'change', {'id': '<?php echo esc_attr( $id ); ?>'}, function ( event ){
282 /* console.log( ':->: on change wpbc_set_shortcode', event.data.id , event ); */
283 wpbc_shortcode_config_fields__booking_ics_import__from_until__support( '<?php echo esc_attr( $id ); ?>' );
284 } );
285 wpbc_shortcode_config_fields__booking_ics_import__from_until__support( '<?php echo esc_attr( $id ); ?>' );
286 });
287 function wpbc_shortcode_config_fields__booking_ics_import__from_until__support( id ){
288 jQuery( '#' + id + '_offset' ).show();
289 if ( 'date' === jQuery( '#' + id ).val() ){
290 jQuery( '.' + id + '_offset_label' ).hide();
291 jQuery( '.' + id + '_date_label' ).show();
292 } else {
293 jQuery( '.' + id + '_offset_label' ).show();
294 jQuery( '.' + id + '_date_label' ).hide();
295 }
296 if ( 'any' === jQuery( '#' + id ).val() ){
297 jQuery( '.' + id + '_offset_label' ).hide();
298 jQuery( '.' + id + '_date_label' ).hide();
299 jQuery( '#' + id + '_offset' ).hide();
300 }
301 }
302 </script><?php
303 ?></fieldset></td>
304 </tr><?php
305 }
306
307 /**
308 * Shortcode Field: Select-box - "Import Conditions"
309 *
310 * @param $id
311 * @param $group_key
312 *
313 * @return void
314 */
315 function wpbc_shortcode_config_fields__booking_ics_import__conditions_import( $id , $group_key ){
316
317 WPBC_Settings_API::field_select_row_static( $id
318 , array(
319 'type' => 'select'
320 , 'title' => __( 'Import condition', 'booking' )
321 , 'description' => __( 'Whether import events for dates, that already booked in specific booking resource', 'booking' )
322 , 'description_tag' => 'span'
323 , 'label' => ''
324 , 'multiple' => false
325 , 'group' => $group_key
326 , 'tr_class' => $group_key . '_standard_section'
327 , 'class' => ''
328 , 'css' => 'margin-right:10px;'
329 , 'only_field' => false
330 , 'attr' => array()
331 , 'value' => ''
332 , 'options' => array(
333 '' => __( 'Import in any case', 'booking' )
334 , 'if_dates_free' => __( 'Import only, if days are available', 'booking' )
335 )
336 )
337 );
338 }
339
340 /**
341 * Shortcode Field: Select-box - "Import Conditions"
342 *
343 * @param $id
344 * @param $group_key
345 *
346 * @return void
347 */
348 function wpbc_shortcode_config_fields__booking_ics_import__conditions_events( $id , $group_key ){
349
350 WPBC_Settings_API::field_select_row_static( $id
351 , array(
352 'type' => 'select'
353 , 'title' => __( 'Event condition', 'booking' )
354 , 'description' => __( 'Import booking, if all dates or only some date(s) within conditional parameters from / until', 'booking' )
355 , 'description_tag' => 'span'
356 , 'label' => ''
357 , 'multiple' => false
358 , 'group' => $group_key
359 , 'tr_class' => $group_key . '_standard_section'
360 , 'class' => ''
361 , 'css' => 'margin-right:10px;'
362 , 'only_field' => false
363 , 'attr' => array()
364 , 'value' => '1'
365 , 'options' => array(
366 '0' => __( 'Some date(s) in conditional interval', 'booking' )
367 , '1' => __( 'Strict. All dates in conditional interval', 'booking' )
368 )
369 )
370 );
371 }
372
373 /**
374 * Shortcode Field: Select-box - "Max Number"
375 *
376 * @param $id
377 * @param $group_key
378 *
379 * @return void
380 */
381 function wpbc_shortcode_config_fields__booking_ics_import__conditions_max_num( $id , $group_key ){
382
383 WPBC_Settings_API::field_select_row_static( $id
384 , array(
385 'type' => 'select'
386 , 'title' => __( 'Maximum number', 'booking' )
387 , 'description' => __( 'You can specify the maximum number of events.', 'booking' )
388 , 'description_tag' => 'span'
389 , 'label' => ''
390 , 'multiple' => false
391 , 'group' => $group_key
392 , 'tr_class' => $group_key . '_standard_section'
393 , 'class' => ''
394 , 'css' => 'margin-right:10px;'
395 , 'only_field' => false
396 , 'attr' => array()
397 , 'value' => 0
398 , 'options' => array_combine(
399 array_merge( array( '0' ), range( 500, 10 , 10 ) )
400 , array_merge( array( '&nbsp;-&nbsp;' ), range( 500, 10 , 10 ) )
401 )
402 )
403 );
404 }
405
406 /**
407 * Shortcode Field: Select-box - "silence"
408 *
409 * @param $id
410 * @param $group_key
411 *
412 * @return void
413 */
414 function wpbc_shortcode_config_fields__booking_ics_import__silence( $id , $group_key ){
415
416 WPBC_Settings_API::field_select_row_static( $id
417 , array(
418 'type' => 'select'
419 , 'title' => __( 'Display Import Status', 'booking' )
420 , 'description' => ''//__( 'You can specify the maximum number of events.', 'booking' )
421 , 'description_tag' => 'span'
422 , 'label' => ''
423 , 'multiple' => false
424 , 'group' => $group_key
425 , 'tr_class' => $group_key . '_standard_section'
426 , 'class' => ''
427 , 'css' => 'margin-right:10px;'
428 , 'only_field' => false
429 , 'attr' => array()
430 , 'value' => 0
431 , 'options' => array(
432 '' => __( 'Show the number of imported bookings', 'booking' )
433 , '1' => __( 'Do not display any messages regarding the import', 'booking' )
434 )
435 )
436 );
437 }
438