PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
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 10.11.2 All 203 releases
booking / core / any / admin-bs-ui.php

admin-bs-ui.php in Booking Calendar 10.1.3, at core/any/admin-bs-ui.php

2,110 lines 138.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.1
3 * @package Any
4 * @category Toolbar. BS UI Elements for Admin Panel.
5 * @author wpdevelop
6 *
7 * @web-site https://wpbookingcalendar.com/
8 * @email info@wpbookingcalendar.com
9 *
10 * @modified 2015-11-14
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly
14
15
16 ////////////////////////////////////////////////////////////////////////////////
17 // Single elements //////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////////////
19
20 /**
21 * Show BS Button
22 *
23 * @param array $item
24 array(
25 'type' => 'button'
26 , 'title' => '' // Title of the button
27 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
28 , 'link' => 'javascript:void(0)' // Direct link or skip it
29 , 'action' => '' // Some JavaScript to execure, for example run the function
30 , 'class' => 'button-secondary' // button-secondary | button-primary
31 , 'icon' => ''
32 , 'font_icon' => ''
33 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
34 , 'style' => '' // Any CSS class here
35 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
36 , 'attr' => array()
37 );
38 */
39 function wpbc_bs_button( $item ) {
40
41 $default_item_params = array(
42 'type' => 'button'
43 , 'title' => '' // Title of the button
44 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
45 , 'link' => 'javascript:void(0)' // Direct link or skip it
46 , 'action' => '' // Some JavaScript to execure, for example run the function
47 , 'class' => 'button-secondary' // button-secondary | button-primary
48 , 'icon' => ''
49 , 'font_icon' => ''
50 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
51 , 'style' => '' // Any CSS class here
52 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
53 , 'attr' => array()
54 );
55 $item_params = wp_parse_args( $item, $default_item_params );
56
57 ?><a class="button <?php
58 echo ( ! empty( $item_params['hint'] ) ) ? ' tooltip_' . $item_params['hint']['position'] . ' ' : '' ;
59 echo $item_params['class'];
60 ?>" style="<?php echo $item_params['style']; ?>"
61 <?php if ( ! empty( $item_params['hint'] ) ) { ?>
62 title="<?php echo esc_js( $item_params['hint']['title'] ); ?>"
63 <?php } ?>
64 href="<?php echo $item_params['link']; ?>"
65 <?php if ( ! empty( $item_params['action'] ) ) { ?>
66 onclick="javascript:<?php echo $item_params['action']; ?>"
67 <?php } ?>
68 <?php echo wpbc_get_custom_attr( $item_params ); ?>
69 ><?php
70 $btn_icon = '';
71 if ( ! empty( $item_params['icon'] ) ) {
72
73 if ( substr( $item_params['icon'], 0, 4 ) != 'http') $img_path = WPBC_PLUGIN_URL . '/assets/img/' . $item_params['icon'];
74 else $img_path = $item_params['icon'];
75
76 $btn_icon = '<img class="menuicons" src="' . $img_path . '" />'; // Img Icon
77
78 } elseif ( ! empty( $item_params['font_icon'] ) ) {
79
80 $btn_icon = '<i class="menu_icon icon-1x ' . $item_params['font_icon'] . '"></i>'; // Font Icon
81
82 }
83 if ( ( ! empty( $btn_icon ) ) && ( $item_params['icon_position'] == 'left' ) ){
84 echo $btn_icon ;
85 if (! empty($item_params['title'])) {
86 echo '&nbsp;';
87 }
88 }
89 // Text
90 echo '<span' . ( ( ( ! empty( $btn_icon ) ) && ( ! $item_params['mobile_show_text'] ) )? ' class="in-button-text"' : '' ) . '>';
91 echo $item_params['title'];
92 if ( ( ! empty( $btn_icon ) ) && ( $item_params['icon_position'] == 'right' ) )
93 echo '&nbsp;' ;
94 echo '</span>';
95
96 if ( ( ! empty( $btn_icon ) ) && ( $item_params['icon_position'] == 'right' ) )
97 echo $btn_icon;
98 ?></a><?php
99 }
100
101
102 /**
103 * Show BS text
104 *
105 * @param array $item
106 array(
107 'id' => '' // HTML ID of element
108 , 'value' => ''
109 , 'placeholder' => ''
110 , 'style' => '' // CSS of select element
111 , 'class' => '' // CSS Class of select element
112 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
113 );
114 */
115 function wpbc_bs_text( $item ) {
116
117 $default_item_params = array(
118 'type' => 'text'
119 , 'id' => ''
120 , 'name' => ''
121 , 'label' => ''
122 , 'disabled' => false
123 , 'class' => ''
124 , 'style' => ''
125 , 'placeholder' => ''
126 , 'attr' => array()
127 , 'value' => ''
128 , 'onfocus' => ''
129 );
130 $item_params = wp_parse_args( $item, $default_item_params );
131
132 ?><input type="<?php echo esc_attr( $item_params['type'] ); ?>"
133 id="<?php echo $item_params['id']; ?>"
134 name="<?php echo $item_params['id']; ?>"
135 style="<?php echo $item_params['style']; ?>"
136 class="form-control <?php echo $item_params['class']; ?>"
137 placeholder="<?php echo $item_params['placeholder']; ?>"
138 value="<?php echo $item_params['value']; ?>"
139 <?php disabled( $item_params['disabled'], true ); ?>
140 <?php echo wpbc_get_custom_attr( $item_params ); ?>
141 <?php
142 if ( ! empty( $item_params['onfocus'] ) ) {
143 ?> onfocus="javascript:<?php echo $item_params['onfocus']; ?>" <?php
144 }
145 ?>
146 /><?php
147 }
148
149
150 /**
151 * Show BS selectbox
152 *
153 * @param array $item
154 array(
155 'id' => '' // HTML ID of element
156 , 'name' => ''
157 , 'style' => '' // CSS of select element
158 , 'class' => '' // CSS Class of select element
159 , 'multiple' => false
160 , 'disabled' => false
161 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
162 , 'options' => array() // Associated array of titles and values
163 , 'disabled_options' => array() // If some options disbaled, then its must list here
164 , 'value' => '' // Some Value from optins array that selected by default
165 , 'onfocus' => ''
166 , 'onchange' => ''
167 )
168 */
169 function wpbc_bs_select( $item ) {
170
171 $default_item_params = array(
172 'id' => '' // HTML ID of element
173 , 'name' => ''
174 , 'style' => '' // CSS of select element
175 , 'class' => '' // CSS Class of select element
176 , 'multiple' => false
177 , 'disabled' => false
178 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
179 , 'options' => array() // Associated array of titles and values
180 , 'disabled_options' => array() // If some options disbaled, then its must list here
181 , 'value' => '' // Some Value from optins array that selected by default
182 , 'onfocus' => ''
183 , 'onchange' => ''
184 );
185 $item_params = wp_parse_args( $item, $default_item_params );
186
187
188 ?><select
189 id="<?php echo esc_attr( $item_params['id'] ); ?>"
190 name="<?php echo esc_attr( $item_params['name'] ); echo ( $item_params['multiple'] ? '[]' : '' ); ?>"
191 class="form-control <?php echo esc_attr( $item_params['class'] ); ?>"
192 style="<?php echo esc_attr( $item_params['style'] ); ?>"
193 <?php disabled( $item_params['disabled'], true ); ?>
194 <?php echo wpbc_get_custom_attr( $item_params ); ?>
195 <?php echo ( $item_params['multiple'] ? ' multiple="MULTIPLE"' : '' ); ?>
196 <?php
197 if ( ! empty( $item_params['onfocus'] ) ) {
198 ?> onfocus="javascript:<?php echo $item_params['onfocus']; ?>" <?php
199 }
200 if ( ! empty( $item_params['onchange'] ) ) {
201 ?> onchange="javascript:<?php echo $item_params['onchange']; ?>" <?php
202 }
203 ?>
204 autocomplete="off"
205 ><?php
206 foreach ( $item_params['options'] as $option_value => $option_data ) {
207
208 if ( ! is_array( $option_data ) ) {
209 $option_data = array( 'title' => $option_data );
210 $is_was_simple = true;
211 } else $is_was_simple = false;
212
213 $default_option_params = array(
214 'id' => '' // HTML ID of element
215 , 'name' => ''
216 , 'style' => '' // CSS of select element
217 , 'class' => '' // CSS Class of select element
218 , 'disabled' => false
219 , 'selected' => false
220 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
221 , 'value' => '' // Some Value from optins array that selected by default
222
223 , 'optgroup' => false // Use only if you need to show OPTGROUP - Also need to use 'title' of start, end 'close' for END
224 , 'close' => false
225
226 );
227 $option_data = wp_parse_args( $option_data, $default_option_params );
228
229 if ( $option_data['optgroup'] ) { // OPTGROUP
230
231 if ( ! $option_data['close'] ) {
232 ?><optgroup label="<?php echo esc_attr( $option_data['title'] ); ?>"><?php
233 } else {
234 ?></optgroup><?php
235 }
236
237 } else { // OPTION
238
239 ?><option
240 value="<?php echo esc_attr( $option_value ); ?>"
241 <?php
242 if ( $is_was_simple ) {
243 selected( $option_value, $item_params['value'] );
244 disabled( in_array( $option_value, $item_params['disabled_options'] ), true );
245 }
246 ?>
247 class="<?php echo esc_attr( $option_data['class'] ); ?>"
248 style="<?php echo esc_attr( $option_data['style'] ); ?>"
249 <?php echo wpbc_get_custom_attr( $option_data ); ?>
250 <?php selected( $option_data['selected'], true ); ?>
251 <?php if ( ! empty( $item_params['value'] ) ) selected( $item_params['value'], esc_attr( $option_value ) ); //Recheck global selected parameter ?>
252 <?php disabled( $option_data['disabled'], true ); ?>
253
254 ><?php echo esc_attr( $option_data['title'] ); ?></option><?php
255 }
256 }
257 ?></select><?php
258 }
259
260
261 /**
262 * Show BS checkbox
263 *
264 * @param array $item
265 array(
266 'type' => 'radio'
267 , 'id' => '' // HTML ID of element
268 , 'name' => ''
269 , 'style' => '' // CSS of select element
270 , 'class' => '' // CSS Class of select element
271 , 'disabled' => false
272 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
273 , 'legend' => '' // aria-label parameter
274 , 'value' => '' // Some Value from optins array that selected by default
275 , 'selected' => false // Selected or not
276 );
277 */
278 function wpbc_bs_radio( $item ) {
279 $item['type'] = 'radio';
280 wpbc_bs_checkbox( $item );
281 }
282
283
284 /**
285 * Show BS checkbox
286 *
287 * @param array $item
288 array(
289 'type' => 'checkbox'
290 , 'id' => '' // HTML ID of element
291 , 'name' => ''
292 , 'style' => '' // CSS of select element
293 , 'class' => '' // CSS Class of select element
294 , 'disabled' => false
295 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
296 , 'legend' => '' // aria-label parameter
297 , 'value' => '' // Some Value from optins array that selected by default
298 , 'selected' => false // Selected or not
299 );
300 */
301 function wpbc_bs_checkbox( $item ) {
302
303 $default_item_params = array(
304 'type' => 'checkbox'
305 , 'id' => '' // HTML ID of element
306 , 'name' => ''
307 , 'style' => '' // CSS of select element
308 , 'class' => '' // CSS Class of select element
309 , 'disabled' => false
310 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
311 , 'legend' => '' // aria-label parameter
312 , 'value' => '' // Some Value from optins array that selected by default
313 , 'selected' => false // Selected or not
314 );
315 $item_params = wp_parse_args( $item, $default_item_params );
316
317 ?><input type="<?php echo esc_attr( $item_params['type'] ); ?>"
318 id="<?php echo esc_attr( $item_params['id'] ); ?>"
319 name="<?php echo esc_attr( $item_params['name'] ); ?>"
320 value="<?php echo esc_attr( $item_params['value'] ); ?>"
321 aria-label="<?php echo esc_attr( $item_params['legend'] ); ?>"
322 class="<?php echo esc_attr( $item_params['class'] ); ?>"
323 style="<?php echo esc_attr( $item_params['style'] ); ?>"
324 <?php echo wpbc_get_custom_attr( $item_params ); ?>
325 <?php checked( $item_params['selected'], true ); ?>
326 <?php disabled( $item_params['disabled'], true ); ?>
327 /><?php
328 }
329
330
331 /**
332 * Show BS addon
333 *
334 * @param array $item
335 array(
336 'type' => 'addon'
337 , 'element' => 'text' // text | radio | checkbox
338 , 'text' => '' // Simple plain text showing
339 , 'id' => '' // ID, if this radio | checkbox element
340 , 'name' => '' // Name, if this radio | checkbox element
341 , 'value' => '' // value, if this radio | checkbox element
342 , 'selected' => false // Selected, if this radio | checkbox element
343 , 'legend' => '' // aria-label parameter , if this radio | checkbox element
344 , 'class' => '' // Any CSS class here
345 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
346 , 'text' => '' // Text tp show for Text element
347 )
348 */
349 function wpbc_bs_addon( $item ) {
350 $milliseconds = round( microtime( true ) * 1000 ); //FixIn: 8.8.2.1
351 $default_item_params = array(
352 'type' => 'addon'
353 , 'element' => 'text' // text | radio | checkbox
354 , 'text' => '' // Simple plain text showing
355 , 'id' => '' // ID, if this radio | checkbox element
356 , 'name' => '' // Name, if this radio | checkbox element
357 , 'value' => '' // value, if this radio | checkbox element
358 , 'selected' => false // Selected, if this radio | checkbox element
359 , 'legend' => '' // aria-label parameter , if this radio | checkbox element
360 , 'class' => '' // Any CSS class here
361 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
362 , 'text' => '' // Text tp show for Text element
363 , 'style' => ''
364 );
365 $item_params = wp_parse_args( $item, $default_item_params );
366
367 ?><span class="input-group-addon"><?php
368 if ( $item_params['element'] == 'text' ) {
369 ?><span class="<?php echo esc_attr( $item_params['class'] ); ?>"
370 style="<?php echo esc_attr( $item_params['style'] ); ?>"><?php
371 echo $item_params['text'];
372 ?></span><?php
373 } elseif ( $item_params['element'] == 'checkbox' ) {
374
375 if ( empty( $item_params['id'] ) )
376 $item_params['id'] = $item_params['element'] . '_grp_' . $milliseconds ;
377
378 if ( empty( $item_params['name'] ) )
379 $item_params['name'] = $item_params['id'];
380
381 ?><input type="checkbox"
382 id="<?php echo $item_params['id']; ?>"
383 name="<?php echo $item_params['name']; ?>"
384 value="<?php echo $item_params['value']; ?>"
385 aria-label="<?php echo $item_params['legend']; ?>"
386 class="<?php echo $item_params['class']; ?>"
387 <?php echo wpbc_get_custom_attr( $item_params ); ?>
388 <?php if ( $item_params['selected'] ) { echo ' checked="CHECKED" '; } ?>
389 /><?php
390
391 } elseif ( $item_params['element'] == 'radio' ) {
392
393 if ( empty( $item_params['id'] ) )
394 $item_params['id'] = $item_params['element'] . '_grp_' . $milliseconds ;
395
396 if ( empty( $item_params['name'] ) )
397 $item_params['name'] = $item_params['id'];
398
399 ?><input type="radio"
400 id="<?php echo $item_params['id']; ?>"
401 name="<?php echo $item_params['name']; ?>"
402 value="<?php echo $item_params['value']; ?>"
403 aria-label="<?php echo $item_params['legend']; ?>"
404 class="<?php echo $item_params['class']; ?>"
405 <?php echo wpbc_get_custom_attr( $item_params ); ?>
406 <?php if ( $item_params['selected'] ) { echo ' checked="CHECKED" '; } ?>
407 /><?php
408 }
409 ?></span><?php
410
411 }
412
413
414 /**
415 * Show BS Dropdown
416 *
417 * @param array $item
418 array(
419
420 );
421 */
422 function wpbc_bs_dropdown( $item ) {
423
424 $default_item_params = array(
425 'id' => '' // HTML ID of element
426 , 'default' => '' // Some Value from optins array that selected by default
427 , 'hint' => '' // Hint // array( 'title' => __('Delete booking' ,'booking') , 'position' => 'bottom' )
428 , 'class' => 'button-secondary'
429 , 'style' => '' // Any CSS style
430 , 'label' => '' // Label of element "at Top of element"
431 , 'title' => '' // Title of element "Inside of element"
432 , 'align' => 'left' // Align: left | right
433 , 'attr' => array()
434 , 'icon' => ''
435 , 'font_icon' => ''
436 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
437 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
438 , 'disabled' => array() // If some options disbaled, then its must list here
439 , 'options' => array() // Associated array of titles and values
440 );
441 $params = wp_parse_args( $item, $default_item_params );
442
443
444 $milliseconds = round(microtime(true) * 1000);
445
446 if ( empty( $params['id'] ) ) $params['id'] = 'wpbc_bs_dropdown' . $milliseconds;
447
448 // Check if this list Simple or Complex (with input elements) ////////////
449 $is_this_simple_list = true; //FixIn: 9.0.1.1.1
450 foreach ( $params['options'] as $key => $value ) {
451 if ( is_array( $value ) ) {
452 $is_this_simple_list = false;
453 break;
454 }
455 }
456
457 ?><a href="javascript:void(0)"
458 <?php if (! $is_this_simple_list ) { ?>
459 onclick="javascript:jQuery('#<?php echo $params['id']; ?>_container').show();"
460 <?php } ?>
461 data-toggle="wpbc_dropdown"
462 id="<?php echo $params['id'];?>_selector"
463 <?php if ( ! empty( $params['hint'] ) ) { ?>
464 title="<?php echo esc_js( $params['hint']['title'] ); ?>"
465 <?php } ?>
466 class="button dropdown-toggle <?php
467 echo ( ! empty( $params['hint'] ) ) ? 'tooltip_' . $params['hint']['position'] . ' ' : '' ;
468 echo ( ! empty( $params['class'] ) ) ? $params['class'] . ' ' : '' ;
469 ?>"
470 style="<?php echo $params['style']; ?>"
471 <?php echo wpbc_get_custom_attr( $params ); ?>
472 ><?php
473
474 $btn_icon = '';
475 if ( ! empty( $params['icon'] ) ) {
476
477 if ( substr( $params['icon'], 0, 4 ) != 'http') $img_path = WPBC_PLUGIN_URL . '/assets/img/' . $params['icon'];
478 else $img_path = $params['icon'];
479
480 $btn_icon = '<img class="menuicons" src="' . $img_path . '" />'; // Img Icon
481
482 } elseif ( ! empty( $params['font_icon'] ) ) {
483
484 $btn_icon = '<i class="menu_icon icon-1x ' . $params['font_icon'] . '"></i>'; // Font Icon
485
486 }
487 if ( ( ! empty( $btn_icon ) ) && ( $params['icon_position'] == 'left' ) )
488 echo $btn_icon . '&nbsp;';
489
490 // Text
491 echo '<span' . ( ( ( ! empty( $btn_icon ) ) && ( ! $params['mobile_show_text'] ) )? ' class="in-button-text"' : '' ) . '>';
492 echo $params['title'];
493 if ( ( ! empty( $btn_icon ) ) && ( $params['icon_position'] == 'right' ) )
494 echo '&nbsp;' ;
495 echo '</span>';
496
497 if ( ( ! empty( $btn_icon ) ) && ( $params['icon_position'] == 'right' ) )
498 echo $btn_icon;
499 ?> &nbsp;<span class="caret"></span></a><?php
500
501 ?><ul
502 id="<?php echo $params['id']; ?>_container"
503 class="dropdown-menu dropdown-menu-<?php echo $params['align']; ?>"
504 ><?php
505
506 wpbc_bs_list_of_options_for_dropdown( $params , 'simple' , $is_this_simple_list);
507
508 ?></ul><?php
509 }
510
511
512 function wpbc_bs_list_of_options_for_dropdown( $params, $dropdown_type = 'simple', $is_this_simple_list = true ) {
513
514 $milliseconds = round( microtime( true ) * 1000 ); //FixIn: 8.8.2.1
515
516 foreach ( $params['options'] as $key => $value ) {
517
518 if ( is_array( $value ) ) { // Complex value constructions
519
520 ?><li role="presentation">
521 <div class="btn-toolbar" role="toolbar">
522 <?php
523 $item_params = reset($value) ;
524
525 $default_item_params = array(
526 'id' => '' // HTML ID of element
527 , 'default' => '' // Some Value from optins array that selected by default
528 , 'hint' => '' // Hint // array( 'title' => __('Delete booking' ,'booking') , 'position' => 'bottom' )
529 , 'class' => 'button-secondary'
530 , 'style' => '' // Any CSS style
531 , 'label' => '' // Label of element "at Top of element"
532 , 'title' => '' // Title of element "Inside of element"
533 , 'align' => 'left' // Align: left | right
534 , 'attr' => array()
535 , 'icon' => ''
536 , 'font_icon' => ''
537 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
538 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
539 , 'disabled' => array() // If some options disbaled, then its must list here
540 , 'options' => array() // Associated array of titles and values
541 );
542 $item_params = wp_parse_args( $item_params, $default_item_params );
543
544 ?>
545 <div class="<?php echo ( $item_params['type'] == 'group' ) ? esc_attr( $item_params['class'] ) : 'input-group'; ?>"
546 style="<?php echo ( $item_params['type'] == 'group' ) ? esc_attr( $item_params['style'] ) : ''; ?>"
547 role="group"><?php
548
549 // Count number of text elements in this LI section
550 $number_of_text_elements = 0;
551 foreach ( $value as $item_params ) {
552 if ( $item_params['type'] == 'text' )
553 $number_of_text_elements++;
554 }
555 $focus_element_id = 'shjgkdfhgjhhsjgkhjkgdhghdjghjdkghjkdhgjkfghdfjhgjdkdgkhjf';
556 foreach ( $value as $item_params ) {
557
558 $item_type = $item_params['type'];
559
560 switch ( $item_type ) {
561
562 case 'checkbox':
563 case 'radio':
564 ?><span class="input-group-addon"><?php
565
566 if ( empty( $item_params['id'] ) ) $item_params['id'] = $params['id'] . '_grp_' . $milliseconds ;
567
568 if ( empty( $item_params['name'] ) ) $item_params['name'] = $item_params['id'];
569
570 $focus_element_id = esc_attr( $item_params['id'] );
571
572 wpbc_bs_checkbox( $item_params );
573
574 if ( ! empty( $item_params['label'] ) ) {
575
576 ?><label for="<?php echo esc_attr( $item_params['id'] ); ?>"><?php
577
578 echo wp_kses_post( $item_params['label'] );
579 ?></label><?php
580 }
581 ?></span><?php
582
583 break;
584
585 case 'select':
586
587 if ( empty( $item_params['id'] ) ) $item_params['id'] = $params['id'] . '_grp_' . $milliseconds ;
588
589 if ( empty( $item_params['name'] ) ) $item_params['name'] = $item_params['id'];
590
591 $item_params['onfocus'] = "jQuery('#" . $focus_element_id ."').prop('checked', true);";
592
593 wpbc_bs_select( $item_params );
594
595 break;
596
597 case 'text':
598
599 if ( empty( $item_params['id'] ) ) $item_params['id'] = $params['id'] . '_grp_' . $milliseconds ;
600
601 if ( empty( $item_params['name'] ) ) $item_params['name'] = $item_params['id'];
602
603 ?><div class="dropdown-menu-text-element <?php echo 'dropdown-menu-text-element-count-' . $number_of_text_elements; ?>"><?php
604
605 if ( ! empty( $item_params['label'] ) ) {
606
607 ?><label for="<?php echo esc_attr( $item_params['id'] ); ?>"><?php
608
609 echo wp_kses_post( $item_params['label'] );
610
611 ?></label><?php
612 }
613
614 ?><legend class="screen-reader-text"><span><?php echo wp_kses_post( $item_params['label'] ); ?></span></legend><?php
615
616 $item_params['onfocus'] = "jQuery('#" . $focus_element_id ."').prop('checked', true);";
617
618 wpbc_bs_text( $item_params );
619
620 ?></div><?php
621
622 break;
623
624 case 'button':
625
626 $default_item_params = array(
627 'action' => "wpbc_close_dropdown_selectbox( '" . $params['id'] . "' )" // Close list and uncheck any checkboxes or radio boxes in dropdown list
628 );
629
630 $item_params = wp_parse_args( $item_params, $default_item_params );
631
632 wpbc_bs_button( $item_params );
633 break;
634
635 default:
636 break;
637 }
638 }
639 ?>
640 </div>
641 </div>
642 </li><?php
643
644 } else {
645
646 if ( $value == 'divider' ) {
647
648 ?><li role="presentation" class="divider"></li><?php
649
650 } elseif ( $value == 'header' ) {
651
652 ?><li role="presentation" class="dropdown-header"><?php echo $key ?></li><?php
653
654 } else {
655 ?><li role="presentation" <?php if ( in_array( $value, $params['disabled'] ) === true ) { echo ' class="disabled"'; } ?> >
656 <a role="menuitem"
657 tabindex="-1"
658 href="javascript:void(0)"
659 <?php
660 if ( in_array( $value, $params['disabled'] ) !== true ) {
661
662 if ( $dropdown_type == 'list' ) { ?>
663
664 onclick="javascript:
665 wpbc_show_selected_in_dropdown('<?php echo $params['id']; ?>', jQuery(this).html(), '<?php echo $value; ?>');
666 <?php if (! $is_this_simple_list ) { ?>
667 wpbc_close_dropdown_selectbox( '<?php echo $params['id']; ?>' );
668 <?php } ?>"
669 <?php } else { ?>
670
671 onclick="javascript:<?php echo $value; ?>"
672 <?php }
673
674 } ?>
675 ><?php echo $key; ?></a>
676 </li><?php
677 }
678 }
679
680 }
681 }
682
683 ////////////////////////////////////////////////////////////////////////////////
684 // Control elements //////////////////////////////////////////////////////
685 ////////////////////////////////////////////////////////////////////////////////
686
687 /**
688 * Button Groups
689 *
690 * @param array $args
691 *
692
693 $params = array(
694 'label_for' => 'actions' // "For" parameter of button group element
695 , 'label' => __('Actions:', 'booking') // Label above the button group
696 , 'style' => '' // CSS Style of entire div element
697 , 'items' => array(
698 array(
699 'type' => 'button'
700 , 'title' => __('Delete', 'booking') // Title of the button
701 , 'hint' => array( 'title' => __('Delete booking' ,'booking') , 'position' => 'bottom' ) // Hint
702 , 'link' => 'javascript:void(0)' // Direct link or skip it
703 , 'action' => '' // Some JavaScript to execure, for example run the function
704 , 'class' => '' // button-secondary | button-primary
705 , 'icon' => ''
706 , 'font_icon' => ''
707 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
708 , 'style' => '' // Any CSS class here
709 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
710 , 'attr' => array()
711 )
712 , array(
713 'type' => 'button'
714 , 'title' => __('Delete', 'booking')
715 , 'class' => 'button-primary'
716 , 'font_icon' => 'wpbc_icn_delete_outline'
717 , 'icon_position' => 'left'
718 , 'action' => "jQuery('#booking_filters_formID').trigger( 'submit' );"
719 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
720 )
721 )
722 );
723 wpbc_bs_button_group( $params );
724
725 */
726 function wpbc_bs_button_group( $args = array() ) {
727
728 $milliseconds = round(microtime(true) * 1000);
729
730 $defaults = array(
731 'label_for' => 'btn_bs_' . $milliseconds // "For" parameter of label element
732 , 'label' => '' // Label above element
733 , 'style' => '' // CSS of entire div element
734 , 'items' => array() // Array of elements
735 );
736
737 $params = wp_parse_args( $args, $defaults );
738
739 ?><div class="control-group" style="<?php echo $params['style']; ?>" ><?php
740 if (! empty( $params['label'] ) ) {
741 ?><label for="<?php echo $params['label_for']; ?>" class="control-label"><?php echo $params['label']; ?></label><?php
742 }
743 ?><div class="btn-toolbar" role="toolbar" aria-label="..." id="<?php echo $params['label_for']; ?>">
744 <div class="btn-group" role="group" aria-label="..."><?php
745
746 foreach ( $params['items'] as $item ) {
747
748 switch ( $item['type'] ) {
749
750 case 'button':
751 wpbc_bs_button( $item );
752 break;
753 case 'dropdown':
754 wpbc_bs_dropdown( $item );
755 break;
756 default:
757 break;
758 }
759
760 } ?>
761 </div>
762 </div>
763 </div><?php
764 }
765
766
767 /**
768 * Show Input Group
769 *
770 * @param array $args
771 *
772
773 $params = array(
774 'label_for' => 'min_cost' // "For" parameter of label element
775 , 'label' => __('Min / Max cost:', 'booking') // Label above the input group
776 , 'style' => '' // CSS Style of entire div element
777 , 'items' => array(
778 array(
779 'type' => 'addon'
780 , 'element' => 'text' // text | radio | checkbox
781 , 'text' => __('Cost', 'booking') . ':'
782 , 'class' => '' // Any CSS class here
783 , 'style' => 'font-weight:600;' // CSS Style of entire div element
784 )
785 , array(
786 'type' => 'addon'
787 , 'element' => 'checkbox' // text | radio | checkbox
788 , 'id' => 'apply_elem' // ID, if this radio | checkbox element
789 , 'name' => 'apply_elem' // Name, if this radio | checkbox element
790 , 'value' => 'On' // value, if this radio | checkbox element
791 , 'selected' => false // Selected, if this radio | checkbox element
792 , 'legend' => '' // aria-label parameter , if this radio | checkbox element
793 , 'class' => '' // Any CSS class here
794 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
795 )
796 , array(
797 'type' => 'addon'
798 , 'element' => 'radio' // text | radio | checkbox
799 , 'id' => 'min_elem' // ID, if this radio | checkbox element
800 , 'name' => 'cost_elem' // Name, if this radio | checkbox element
801 , 'value' => 'min' // value, if this radio | checkbox element
802 , 'selected' => false // Selected, if this radio | checkbox element
803 , 'legend' => '' // aria-label parameter , if this radio | checkbox element
804 , 'class' => '' // Any CSS class here
805 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
806 )
807 // Warning! Can be text or selectbox, not both OR you need to define width
808 , array(
809 'type' => 'text'
810 , 'id' => 'min_cost' // HTML ID of element
811 , 'value' => '' // Value of Text field
812 , 'placeholder' => __('Reason of Cancelation', 'booking')
813 , 'style' => 'width:100px;' // CSS of select element
814 , 'class' => '' // CSS Class of select element
815 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
816 )
817 , array(
818 'type' => 'addon'
819 , 'element' => 'text' // text | radio | checkbox
820 , 'text' => ' - ' // Simple plain text showing
821 )
822 , array(
823 'type' => 'text'
824 , 'id' => 'max_cost' // HTML ID of element
825 , 'value' => '' // Value of Text field
826 , 'placeholder' => __('Max Cost', 'booking')
827 , 'style' => '' // CSS of select element
828 , 'class' => '' // CSS Class of select element
829 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
830
831 )
832 , array(
833 'type' => 'addon'
834 , 'element' => 'radio' // text | radio | checkbox
835 , 'id' => 'max_elem' // ID, if this radio | checkbox element
836 , 'name' => 'cost_elem' // Name, if this radio | checkbox element
837 , 'value' => 'max' // value, if this radio | checkbox element
838 , 'selected' => false // Selected, if this radio | checkbox element
839 , 'legend' => '' // aria-label parameter , if this radio | checkbox element
840 , 'class' => '' // Any CSS class here
841 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
842 )
843 // Warning! Can be text or selectbox, not both OR you need to define width
844 , array(
845 'type' => 'select'
846 , 'id' => 'select_option' // HTML ID of element
847 , 'options' => array( 'delete' => __('Delete', 'booking'), 'any' => __('Any','booking'), 'specific' => __('Specific', 'booking') ) // Associated array of titles and values
848 , 'disabled_options' => array( 'any' ) // If some options disbaled, then its must list here
849 , 'default' => 'specific' // Some Value from optins array that selected by default
850 , 'style' => 'width:200px;' // CSS of select element
851 , 'class' => '' // CSS Class of select element
852 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
853 )
854
855 // Select Advanced option list
856 , array(
857 'type' => 'select'
858 , 'id' => 'select_form_help_shortcode'
859 , 'name' => 'select_form_help_shortcode'
860 , 'style' => ''
861 , 'class' => ''
862 , 'multiple' => false
863 , 'disabled' => false
864 , 'disabled_options' => array() // If some options disbaled, then its must list here
865 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
866 , 'options' => array( // Associated array of titles and values
867 'info' => array(
868 'title' => __('General Info', 'booking')
869 , 'id' => ''
870 , 'name' => ''
871 , 'style' => ''
872 , 'class' => ''
873 , 'disabled' => false
874 , 'selected' => false
875 , 'attr' => array()
876 )
877 , 'optgroup_sf_s' => array(
878 'optgroup' => true
879 , 'close' => false
880 , 'title' => '&nbsp;' . __('Standard Fields' ,'booking')
881 )
882 , 'text' => array(
883 'title' => __('Text', 'booking')
884 , 'id' => ''
885 , 'name' => ''
886 , 'style' => ''
887 , 'class' => ''
888 , 'disabled' => false
889 , 'selected' => false
890 , 'attr' => array()
891 )
892 , 'select' => array(
893 'title' => __('Select', 'booking')
894 , 'id' => ''
895 , 'name' => ''
896 , 'style' => ''
897 , 'class' => ''
898 , 'disabled' => false
899 , 'selected' => false
900 , 'attr' => array()
901 )
902 , 'textarea' => array(
903 'title' => __('Textarea', 'booking')
904 , 'id' => ''
905 , 'name' => ''
906 , 'style' => ''
907 , 'class' => ''
908 , 'disabled' => false
909 , 'selected' => false
910 , 'attr' => array()
911 )
912 , 'checkbox' => array(
913 'title' => __('Checkbox', 'booking')
914 , 'id' => ''
915 , 'name' => ''
916 , 'style' => ''
917 , 'class' => ''
918 , 'disabled' => false
919 , 'selected' => false
920 , 'attr' => array()
921 )
922 , 'optgroup_sf_e' => array( 'optgroup' => true, 'close' => true )
923
924
925 , 'optgroup_af_s' => array(
926 'optgroup' => true
927 , 'close' => false
928 , 'title' => '&nbsp;' . __('Advanced Fields' ,'booking')
929 )
930 , 'info_advanced' => array(
931 'title' => __('Info', 'booking')
932 , 'id' => ''
933 , 'name' => ''
934 , 'style' => ''
935 , 'class' => ''
936 , 'disabled' => false
937 , 'selected' => false
938 , 'attr' => array()
939 )
940 , 'optgroup_af_e' => array( 'optgroup' => true, 'close' => true )
941
942 )
943 , 'value' => '' // Some Value from optins array that selected by default
944 , 'onfocus' => ''
945 , 'onchange' => "jQuery('.wpbc_field_generator').hide();jQuery('.wpbc_field_generator_' + this.options[this.selectedIndex].value ).show();"
946 )
947 , array(
948 'type' => 'button'
949 , 'title' => __('Delete', 'booking') // Title of the button
950 , 'hint' => array( 'title' => __('Delete booking' ,'booking') , 'position' => 'bottom' ) // Hint
951 , 'link' => 'javascript:void(0)' // Direct link or skip it
952 , 'action' => '' // Some JavaScript to execure, for example run the function
953 , 'class' => '' // button-secondary | button-primary
954 , 'icon' => ''
955 , 'font_icon' => ''
956 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
957 , 'style' => '' // Any CSS class here
958 , 'attr' => array()
959 )
960 , array(
961 'type' => 'button'
962 , 'title' => __('Delete', 'booking')
963 , 'class' => 'button-primary'
964 , 'font_icon' => 'wpbc_icn_delete_outline'
965 , 'icon_position' => 'left'
966 , 'action' => "jQuery('#booking_filters_formID').trigger( 'submit' );"
967 )
968 )
969 );
970 ?><div class="control-group wpbc-no-padding" style="max-width:730px;"><?php
971 wpbc_bs_input_group( $params );
972 ?></div><?php
973
974 */
975 function wpbc_bs_input_group( $args = array() ) {
976
977 $milliseconds = round(microtime(true) * 1000);
978
979 $defaults = array(
980 'label_for' => 'btn_bs_' . $milliseconds // "For" parameter of label element
981 , 'label' => '' // Label above element
982 , 'style' => '' // CSS of entire div element
983 , 'items' => array() // Array of elements
984 );
985
986 $params = wp_parse_args( $args, $defaults );
987
988 ?><div class="wpbc-no-padding" style="width:auto;<?php echo $params['style']; ?>" ><?php
989 if (! empty( $params['label'] ) ) {
990 ?><label for="<?php echo $params['label_for']; ?>" class="control-label"><?php echo $params['label']; ?></label><?php
991 }
992 ?><div class="btn-toolbar" role="toolbar" aria-label="..." id="<?php echo $params['label_for']; ?>_toolbar">
993 <div class="input-group" role="group" aria-label="..."><?php
994
995 foreach ( $params['items'] as $item ) {
996
997 switch ( $item['type'] ) {
998
999 case 'button':
1000 ?><div class="input-group-btn"><?php
1001
1002 wpbc_bs_button( $item );
1003
1004 ?></div><?php
1005 break;
1006
1007 case 'text':
1008 wpbc_bs_text( $item );
1009 break;
1010
1011 case 'select':
1012 wpbc_bs_select( $item );
1013 break;
1014
1015 case 'addon': //FixIn: 9.5.4.9
1016 $item['style'] = empty($item['style']) ? 'line-height: 21px;' : $item['style'] . 'line-height: 21px;margin-right: -10px;'; //FixIn: 9.5.4.9
1017 wpbc_bs_addon( $item );
1018 ?></div><!-- /input-group -->
1019 </div>
1020 </div>
1021 </div>
1022 <div class="control-group wpbc-no-padding">
1023 <div class="wpbc-no-padding" style="width:auto;<?php echo $params['style']; ?>" >
1024 <div class="btn-toolbar" role="toolbar" aria-label="..." id="<?php echo $params['label_for']; ?>_toolbar">
1025 <div class="input-group" role="group" aria-label="..."><?php
1026
1027 break;
1028 default:
1029 break;
1030 }
1031 }
1032
1033 ?></div><!-- /input-group -->
1034 </div>
1035 </div><?php
1036 }
1037
1038
1039 /**
1040 * Selectbox - Dropdown List with comple UI elements
1041 *
1042 * @param array $args = array(
1043 'id' => '' // HTML ID of element
1044 , 'id2' => '' // (optional) HTML ID of 2nd element
1045 , 'default' => '' // Some Value from optins array that selected by default
1046 , 'default2' => '' // (optional) Some Value from optins array that selected by default
1047 , 'hint' => '' // (optional) Hint: array( 'title' => __('Delete booking' ,'booking') , 'position' => 'bottom' )
1048 , 'css_classes' => '' // (optional)
1049 , 'label' => '' // (optional) Label of element "at Top of element"
1050 , 'title' => '' // Title of element "Inside of element"
1051 , 'align' => 'left' // (optional) Align: left | right
1052 , 'disabled' => array() // (optional) If some options disbaled, then its must list here
1053 , 'options' => array( // Associated array of titles and values
1054 __('Bla bla bla', 'booking') => '1'
1055 , 'divider0' => 'divider'
1056 , __('Section Header', 'booking') => 'header'
1057 ...
1058
1059 , '_radio_or_checkbox' => array(
1060 array( 'type' => 'radio' // 'radio' or 'checkbox'
1061 , 'id' => $item_params['id'] // HTML ID of element
1062 , 'name' => $item_params['name']
1063 , 'style' => '' // CSS of select element
1064 , 'class' => '' // CSS Class of select element
1065 , 'disabled' => false
1066 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1067 , 'legend' => '' // aria-label parameter
1068 , 'value' => '' // Some Value from optins array that selected by default
1069 , 'selected' => false // Selected or not
1070 , 'label' => '' // Label - title
1071 )
1072 )
1073 , '_select' => array(
1074 array( 'type' => 'select'
1075 , 'id' => '' // HTML ID of element
1076 , 'style' => '' // CSS of select element
1077 , 'class' => '' // CSS Class of select element
1078 , 'multiple' => false
1079 , 'disabled' => false
1080 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1081 , 'options' => array() // Associated array of titles and values
1082 , 'disabled_options' => array() // If some options disbaled, then its must list here
1083 , 'value' => '' // Some Value from optins array that selected by default
1084 )
1085 )
1086 , '_texts' => array(
1087 array( 'type' => 'text'
1088 , 'id' => ''
1089 , 'name' => ''
1090 , 'label' => ''
1091 , 'disabled' => false
1092 , 'class' => ''
1093 , 'style' => ''
1094 , 'placeholder' => ''
1095 , 'attr' => array()
1096 , 'value' => ''
1097 )
1098 )
1099 , '_buttons' => array(
1100 array( 'type' => 'button'
1101 , 'title' => '' // Title of the button
1102 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
1103 , 'link' => 'javascript:void(0)' // Direct link or skip it
1104 , 'action' => "wpbc_close_dropdown_selectbox( '" . $params['id'] . "' )" // Some JavaScript to execure, for example run the function
1105 , 'class' => 'button-secondary' // button-secondary | button-primary
1106 , 'icon' => ''
1107 , 'font_icon' => ''
1108 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
1109 , 'style' => '' // Any CSS class here
1110 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
1111 , 'attr' => array()
1112 )
1113 )
1114 )
1115 );
1116 *
1117 Exmaple #1:
1118 $params = array( // Pending, Active, Suspended, Terminated, Cancelled, Fraud
1119 'id' => 'wh_approved'
1120 , 'options' => array (
1121 __('Pending', 'booking') => '0',
1122 __('Approved', 'booking') => '1',
1123 , 'divider0' => 'divider'
1124 , __('Section Header', 'booking') => 'header'
1125 , __('Any', 'booking') => ''
1126 )
1127 , 'disabled' => array( '' ) // It will disable "Any" option
1128 , 'default' => ( isset( $_REQUEST[ 'wh_approved' ] ) ) ? esc_attr( $_REQUEST[ 'wh_approved' ] ) : ''
1129 , 'label' => ''//__('Status', 'booking') . ':'
1130 , 'title' => __('Bookings', 'booking')
1131 );
1132
1133 wpbc_bs_dropdown_list( $params );
1134
1135 Exmaple #2:
1136 $dates_interval = array(
1137 1 => '1' . ' ' . __('day' ,'booking')
1138 , 2 => '2' . ' ' . __('days' ,'booking')
1139 , 3 => '3' . ' ' . __('days' ,'booking')
1140 , 4 => '4' . ' ' . __('days' ,'booking')
1141 , 5 => '5' . ' ' . __('days' ,'booking')
1142 , 6 => '6' . ' ' . __('days' ,'booking')
1143 , 7 => '1' . ' ' . __('week' ,'booking')
1144 , 14 => '2' . ' ' . __('weeks' ,'booking')
1145 , 30 => '1' . ' ' . __('month' ,'booking')
1146 , 60 => '2' . ' ' . __('months' ,'booking')
1147 , 90 => '3' . ' ' . __('months' ,'booking')
1148 , 183 => '6' . ' ' . __('months' ,'booking')
1149 , 365 => '1' . ' ' . __('Year' ,'booking')
1150 );
1151 $params = array(
1152 'id' => 'wh_booking_date'
1153 , 'id2' => 'wh_booking_date2'
1154 , 'default' => ( isset( $_REQUEST[ 'wh_booking_date' ] ) ) ? esc_attr( $_REQUEST[ 'wh_booking_date' ] ) : ''
1155 , 'default2' => ( isset( $_REQUEST[ 'wh_booking_date2' ] ) ) ? esc_attr( $_REQUEST[ 'wh_booking_date2' ] ) : ''
1156 , 'hint' => array( 'title' => __('Filter bookings by booking dates' ,'booking') , 'position' => 'top' )
1157 , 'label' => ''//__('Booked Dates', 'booking') . ':'
1158 , 'title' => __('Dates', 'booking')
1159 , 'options' => array (
1160 __('Current dates' ,'booking') => '0'
1161 , __('Today' ,'booking') => '1'
1162 , __('Previous dates' ,'booking') => '2'
1163 , __('All dates' ,'booking') => '3'
1164 , 'divider1' => 'divider'
1165 , __('Today check in/out' ,'booking') => '9'
1166 , __('Check In - Tomorrow' ,'booking') => '7'
1167 , __('Check Out - Tomorrow' ,'booking') => '8'
1168 , 'divider2' => 'divider'
1169 , 'next' => array(
1170 array(
1171 'type' => 'radio'
1172 , 'label' => __('Next' ,'booking')
1173 , 'id' => 'wh_booking_datedays_interval1'
1174 , 'name' => 'wh_booking_datedays_interval_Radios'
1175 , 'style' => '' // CSS of select element
1176 , 'class' => '' // CSS Class of select element
1177 , 'disabled' => false
1178 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1179 , 'legend' => '' // aria-label parameter
1180 , 'value' => '4' // Some Value from optins array that selected by default
1181 , 'selected' => ( isset($_REQUEST[ 'wh_booking_datedays_interval_Radios'] )
1182 && ( $_REQUEST[ 'wh_booking_datedays_interval_Radios'] == '4' ) ) ? true : false
1183 )
1184 , array(
1185 'type' => 'select'
1186 , 'attr' => array()
1187 , 'name' => 'wh_booking_datenext'
1188 , 'id' => 'wh_booking_datenext'
1189 , 'options' => $dates_interval
1190 , 'value' => isset( $_REQUEST[ 'wh_booking_datenext'] ) ? esc_attr( $_REQUEST[ 'wh_booking_datenext'] ) : ''
1191 )
1192 )
1193 , 'prior' => array(
1194 array(
1195 'type' => 'radio'
1196 , 'label' => __('Prior' ,'booking')
1197 , 'id' => 'wh_booking_datedays_interval2'
1198 , 'name' => 'wh_booking_datedays_interval_Radios'
1199 , 'style' => '' // CSS of select element
1200 , 'class' => '' // CSS Class of select element
1201 , 'disabled' => false
1202 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1203 , 'legend' => '' // aria-label parameter
1204 , 'value' => '5' // Some Value from optins array that selected by default
1205 , 'selected' => ( isset($_REQUEST[ 'wh_booking_datedays_interval_Radios'] )
1206 && ( $_REQUEST[ 'wh_booking_datedays_interval_Radios'] == '5' ) ) ? true : false
1207 )
1208 , array(
1209 'type' => 'select'
1210 , 'attr' => array()
1211 , 'name' => 'wh_booking_dateprior'
1212 , 'id' => 'wh_booking_dateprior'
1213 , 'options' => $dates_interval
1214 , 'value' => isset( $_REQUEST[ 'wh_booking_dateprior'] ) ? esc_attr( $_REQUEST[ 'wh_booking_dateprior'] ) : ''
1215 )
1216 )
1217 , 'fixed' => array( array( 'type' => 'group', 'class' => 'input-group text-group'),
1218 array(
1219 'type' => 'radio'
1220 , 'label' => __('Dates' ,'booking')
1221 , 'id' => 'wh_booking_datedays_interval3'
1222 , 'name' => 'wh_booking_datedays_interval_Radios'
1223 , 'style' => '' // CSS of select element
1224 , 'class' => '' // CSS Class of select element
1225 , 'disabled' => false
1226 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1227 , 'legend' => '' // aria-label parameter
1228 , 'value' => '6' // Some Value from optins array that selected by default
1229 , 'selected' => ( isset($_REQUEST[ 'wh_booking_datedays_interval_Radios'] )
1230 && ( $_REQUEST[ 'wh_booking_datedays_interval_Radios'] == '6' ) ) ? true : false
1231 )
1232 , array(
1233 'type' => 'text'
1234 , 'id' => 'wh_booking_datefixeddates'
1235 , 'name' => 'wh_booking_datefixeddates'
1236 , 'label' => __('Check-in' ,'booking') . ':'
1237 , 'disabled' => false
1238 , 'class' => 'wpdevbk-filters-section-calendar' // This class add datepicker
1239 , 'style' => ''
1240 , 'placeholder' => date( 'Y-m-d' )
1241 , 'attr' => array()
1242 , 'value' => isset( $_REQUEST[ 'wh_booking_datefixeddates'] ) ? esc_attr( $_REQUEST[ 'wh_booking_datefixeddates'] ) : ''
1243 )
1244 , array(
1245 'type' => 'text'
1246 , 'id' => 'wh_booking_date2fixeddates'
1247 , 'name' => 'wh_booking_date2fixeddates'
1248 , 'label' => __('Check-out' ,'booking') . ':'
1249 , 'disabled' => false
1250 , 'class' => 'wpdevbk-filters-section-calendar' // This class add datepicker
1251 , 'style' => ''
1252 , 'placeholder' => date( 'Y-m-d' )
1253 , 'attr' => array()
1254 , 'value' => isset( $_REQUEST[ 'wh_booking_date2fixeddates'] ) ? esc_attr( $_REQUEST[ 'wh_booking_date2fixeddates'] ) : ''
1255 )
1256 )
1257 , 'divider3' => 'divider'
1258 , 'custom' => array( array( 'type' => 'group', 'class' => 'input-group text-group')
1259 , array(
1260 'type' => 'radio'
1261 , 'label' => __('Tada' ,'booking')
1262 , 'id' => 'wh_booking_datedays_interval4'
1263 , 'name' => 'wh_booking_datedays_interval_Radios'
1264 , 'style' => '' // CSS of select element
1265 , 'class' => '' // CSS Class of select element
1266 , 'disabled' => false
1267 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1268 , 'legend' => '' // aria-label parameter
1269 , 'value' => '10' // Some Value from optins array that selected by default
1270 , 'selected' => ( isset($_REQUEST[ 'wh_booking_datedays_interval_Radios'] )
1271 && ( $_REQUEST[ 'wh_booking_datedays_interval_Radios'] == '10' ) ) ? true : false
1272 )
1273
1274 , array(
1275 'type' => 'text'
1276 , 'id' => 'wh_booking_datecustom'
1277 , 'name' => 'wh_booking_datecustom'
1278 , 'label' => __('Custom' ,'booking') . ':'
1279 , 'disabled' => false
1280 , 'class' => ''
1281 , 'style' => ''
1282 , 'placeholder' => date( 'Y' )
1283 , 'attr' => array()
1284 , 'value' => isset( $_REQUEST[ 'wh_booking_datecustom'] ) ? esc_attr( $_REQUEST[ 'wh_booking_datecustom'] ) : ''
1285 )
1286 )
1287 , 'divider4' => 'divider'
1288 , 'buttons' => array( array( 'type' => 'group', 'class' => 'btn-group' ),
1289 array(
1290 'type' => 'button'
1291 , 'title' => __('Apply' ,'booking') // Title of the button
1292 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
1293 , 'link' => 'javascript:void(0)' // Direct link or skip it
1294 , 'action' => "wpbc_show_selected_in_dropdown__radio_select_option("
1295 . " 'wh_booking_date'"
1296 . ", 'wh_booking_date2'"
1297 . ", 'wh_booking_datedays_interval_Radios' "
1298 . ");"
1299 // Some JavaScript to execure, for example run the function
1300 , 'class' => 'button-primary' // button-secondary | button-primary
1301 , 'icon' => ''
1302 , 'font_icon' => ''
1303 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
1304 , 'style' => '' // Any CSS class here
1305 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
1306 , 'attr' => array()
1307
1308 )
1309 , array(
1310 'type' => 'button'
1311 , 'title' => __('Close' ,'booking') // Title of the button
1312 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
1313 , 'link' => 'javascript:void(0)' // Direct link or skip it
1314 //, 'action' => '' // Some JavaScript to execure, for example run the function
1315 , 'class' => 'button-secondary' // button-secondary | button-primary
1316 , 'icon' => ''
1317 , 'font_icon' => ''
1318 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
1319 , 'style' => '' // Any CSS class here
1320 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
1321 , 'attr' => array()
1322 )
1323 )
1324 )
1325 );
1326 wpbc_bs_dropdown_list( $params );
1327
1328
1329 Exmaple #3:
1330 $params = array(
1331 'id' => 'wh_pay_status'
1332 // , 'id2' => 'wh_booking_date2'
1333 , 'default' => ( isset( $_REQUEST[ 'wh_pay_status' ] ) ) ? esc_attr( $_REQUEST[ 'wh_pay_status' ] ) : 'all'
1334 // , 'default2' => ( isset( $_REQUEST[ 'wh_booking_date2' ] ) ) ? esc_attr( $_REQUEST[ 'wh_booking_date2' ] ) : ''
1335 , 'hint' => array( 'title' => __('Payment status' ,'booking') , 'position' => 'top' )
1336 , 'label' => ''//__('Booked Dates', 'booking') . ':'
1337 , 'title' => __('Payment', 'booking')
1338 , 'options' => array (
1339 __('Any Status' ,'booking') =>'all',
1340 'divider0' => 'divider',
1341 __('Paid OK' ,'booking') =>'group_ok',
1342 __('Unknown Status' ,'booking') =>'group_unknown',
1343 __('Not Completed' ,'booking') =>'group_pending',
1344 __('Failed' ,'booking') =>'group_failed'
1345 , 'divider2' => 'divider'
1346 , 'custom' => array( array( 'type' => 'group', 'class' => 'input-group text-group')
1347 , array(
1348 'type' => 'radio'
1349 , 'label' => __('Custom' ,'booking')
1350 , 'id' => 'wh_pay_statuscustom_radios1'
1351 , 'name' => 'wh_pay_statuscustom_Radios'
1352 , 'style' => '' // CSS of select element
1353 , 'class' => '' // CSS Class of select element
1354 , 'disabled' => false
1355 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1356 , 'legend' => '' // aria-label parameter
1357 , 'value' => '1' // Some Value from optins array that selected by default
1358 , 'selected' => ( isset($_REQUEST[ 'wh_pay_statuscustom_Radios'] )
1359 && ( $_REQUEST[ 'wh_pay_statuscustom_Radios'] == '1' ) ) ? true : false
1360 )
1361
1362 , array(
1363 'type' => 'text'
1364 , 'id' => 'wh_pay_statuscustom'
1365 , 'name' => 'wh_pay_statuscustom'
1366 , 'label' => __('Payment status' ,'booking') . ':'
1367 , 'disabled' => false
1368 , 'class' => ''
1369 , 'style' => ''
1370 , 'placeholder' => ''
1371 , 'attr' => array()
1372 , 'value' => isset( $_REQUEST[ 'wh_pay_statuscustom'] ) ? esc_attr( $_REQUEST[ 'wh_pay_statuscustom'] ) : ''
1373 )
1374 )
1375 , 'divider4' => 'divider'
1376 , 'buttons' => array( array( 'type' => 'group', 'class' => 'btn-group' ),
1377 array(
1378 'type' => 'button'
1379 , 'title' => __('Apply' ,'booking') // Title of the button
1380 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
1381 , 'link' => 'javascript:void(0)' // Direct link or skip it
1382 , 'action' => "wpbc_show_selected_in_dropdown__radio_select_option("
1383 . " 'wh_pay_status'"
1384 . ", ''"
1385 . ", 'wh_pay_statuscustom_Radios' "
1386 . ");"
1387 // Some JavaScript to execure, for example run the function
1388 , 'class' => 'button-primary' // button-secondary | button-primary
1389 , 'icon' => ''
1390 , 'font_icon' => ''
1391 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
1392 , 'style' => '' // Any CSS class here
1393 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
1394 , 'attr' => array()
1395
1396 )
1397 , array(
1398 'type' => 'button'
1399 , 'title' => __('Close' ,'booking') // Title of the button
1400 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
1401 , 'link' => 'javascript:void(0)' // Direct link or skip it
1402 //, 'action' => '' // Some JavaScript to execure, for example run the function
1403 , 'class' => 'button-secondary' // button-secondary | button-primary
1404 , 'icon' => ''
1405 , 'font_icon' => ''
1406 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
1407 , 'style' => '' // Any CSS class here
1408 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
1409 , 'attr' => array()
1410 )
1411 )
1412 )
1413 );
1414 wpbc_bs_dropdown_list( $params );
1415
1416 */
1417 function wpbc_bs_dropdown_list( $args = array() ) {
1418
1419 $milliseconds = round(microtime(true) * 1000);
1420
1421 $defaults = array(
1422 'id' => '' // HTML ID of element
1423 , 'id2' => '' // HTML ID of 2nd element
1424 , 'default' => '' // Some Value from optins array that selected by default
1425 , 'default2' => '' // Some Value from optins array that selected by default
1426 , 'hint' => '' // Hint // array( 'title' => __('Delete booking' ,'booking') , 'position' => 'bottom' )
1427 , 'css_classes' => ''
1428 , 'label' => '' // Label of element "at Top of element"
1429 , 'title' => '' // Title of element "Inside of element"
1430 , 'align' => 'left' // Align: left | right
1431 , 'options' => array() // Associated array of titles and values
1432 , 'disabled' => array() // If some options disbaled, then its must list here
1433 );
1434 $params = wp_parse_args( $args, $defaults );
1435
1436 // Check if this list Simple or Complex (with input elements) ////////////
1437 $is_this_simple_list = true; //FixIn: 9.0.1.1.1
1438 foreach ( $params['options'] as $key => $value ) {
1439 if ( is_array( $value ) ) {
1440 $is_this_simple_list = false;
1441 break;
1442 }
1443 }
1444
1445 // Selected Value //////////////////////////////////////////////////////////
1446 $wpbc_value = $params[ 'default' ];
1447
1448 $wpbc_selector_default = array_search( $wpbc_value, $params['options'] );
1449 if ( $wpbc_selector_default === false ) {
1450 $wpbc_selector_default = key( $params['options'] );
1451 $wpbc_selector_default_value = current( $params['options'] );
1452 } else
1453 $wpbc_selector_default_value = $wpbc_value;
1454
1455 $wpbc_selector_default_value2 = $params[ 'default2' ];
1456
1457 // Initial setting title, if already was request /////////////////////////
1458 if ( isset( $_REQUEST[ esc_attr( $params['id'] ) ] ) ) {
1459 ?><script type="text/javascript">
1460 jQuery(document).ready( function(){
1461 jQuery('#<?php echo esc_attr( $params['id'] ); ?>_container .button.button-primary').trigger( "click" );
1462 });
1463 </script><?php
1464 }
1465 ////////////////////////////////////////////////////////////////////////////
1466 ?>
1467 <div class="control-group">
1468 <?php if ( ! empty( $params['label'] ) ) {
1469 ?><label for="<?php echo $params['id']; ?>" class="control-label"><?php echo $params['label']; ?></label><?php
1470 }
1471 ?><div>
1472 <div class="btn-group">
1473 <a href="javascript:void(0)"
1474 <?php if (! $is_this_simple_list ) { ?>
1475 onclick="javascript:jQuery('#<?php echo $params['id']; ?>_container').show();"
1476 <?php } ?>
1477 data-toggle="wpbc_dropdown"
1478 id="<?php echo $params['id'];?>_selector"
1479 <?php if ( ! empty( $params['hint'] ) ) { ?>
1480 title="<?php echo esc_js( $params['hint']['title'] ); ?>"
1481 <?php } ?>
1482 class="button button-secondary dropdown-toggle <?php
1483 echo ( ! empty( $params['hint'] ) ) ? 'tooltip_' . $params['hint']['position'] . ' ' : '' ;
1484 echo ( ! empty( $params['css_classes'] ) ) ? $params['css_classes'] . ' ' : '' ;
1485 ?>"
1486 <?php echo wpbc_get_custom_attr( $params ); ?>
1487 ><label class="label_in_filters"
1488 ><?php echo $params['title']; ?>: </label> <span class="wpbc_selected_in_dropdown"><?php echo $wpbc_selector_default; ?></span> &nbsp; <span class="caret"></span></a>
1489 <ul
1490 id="<?php echo $params['id']; ?>_container"
1491 class="dropdown-menu dropdown-menu-<?php echo $params['align']; ?>"
1492 ><?php
1493
1494 wpbc_bs_list_of_options_for_dropdown( $params , 'list', $is_this_simple_list );
1495
1496 ?></ul>
1497 <input type="hidden" autocomplete="off" value="<?php echo $wpbc_selector_default_value; ?>" id="<?php echo $params['id']; ?>" name="<?php echo $params['id']; ?>" />
1498 <?php if ( ! empty($params['id2'] ) ) { ?>
1499 <input type="hidden" autocomplete="off" value="<?php echo $wpbc_selector_default_value2; ?>" id="<?php echo $params['id2']; ?>" name="<?php echo $params['id2']; ?>" />
1500 <?php } ?>
1501 </div>
1502 </div>
1503 </div>
1504 <?php
1505 }
1506
1507
1508
1509 ////////////////////////////////////////////////////////////////////////////////
1510 // Drop Down Menu
1511 ////////////////////////////////////////////////////////////////////////////////
1512
1513 /**
1514 * Show Dropdown Menu
1515 *
1516 * Usage:
1517
1518 wpbc_dropdown_menu( array(
1519 'title' => __('Help', 'booking')
1520 , 'hint' => array( 'title' => __('Help info' ,'booking') , 'position' => 'bottom' )
1521 , 'font_icon' => 'glyphicon glyphicon-question-sign'
1522 , 'position' => 'right'
1523 , 'items' => array(
1524 array( 'type' => 'link', 'title' => __('About Plugin', 'booking'), 'url' => 'https://wpbookingcalendar.com /' )
1525 , array( 'type' => 'divider' )
1526 , array( 'type' => 'text', 'title' => __('Text', 'booking') )
1527 , array( 'type' => 'link', 'title' => __('Help', 'booking'), 'url' => 'https://wpbookingcalendar.com/help/' )
1528 , array( 'type' => 'link', 'title' => __('FAQ', 'booking'), 'url' => 'https://wpbookingcalendar.com/faq/' )
1529 , array( 'type' => 'link', 'title' => __('Technical Support', 'booking'), 'url' => 'https://wpbookingcalendar.com/support/' )
1530 , array( 'type' => 'divider' )
1531 , array( 'type' => 'link', 'title' => __('Upgrade Now', 'booking'), 'url' => 'https://wpbookingcalendar.com/', 'style' => 'font-weight: 600;' , 'attr' => array( 'target' => '_blank' ) )
1532 )
1533 ) );
1534 *
1535 * @param array $args
1536 */
1537 function wpbc_bs_dropdown_menu( $args = array() ) {
1538
1539 $defaults = array(
1540 'title' => '',
1541 'hint' => '',
1542 'icon' => '',
1543 'font_icon' => '',
1544 'position' => '',
1545 'style' => '',
1546 'items' => array()
1547 );
1548 $params = wp_parse_args( $args, $defaults );
1549
1550 ?><span class="dropdown <?php echo ( ( $params['position'] == 'right' ) ? 'pull-right' : '' ); ?>" style="<?php echo esc_attr( $params['style'] ); ?>">
1551 <a href="javascript:void(0)"
1552 data-toggle="wpbc_dropdown"
1553 aria-expanded="true"
1554 <?php if ( ! empty( $params['hint'] ) ) { ?>
1555 title="<?php echo esc_js( $params['hint']['title'] ); ?>"
1556 <?php } ?>
1557 class="dropdown-toggle nav-tab <?php
1558 echo ( ! empty( $params['hint'] ) ) ? 'tooltip_' . $params['hint']['position'] . ' ' : '' ;
1559 ?>"><?php
1560
1561 if ( ! empty( $params['icon'] ) ) {
1562
1563 if ( substr( $params['icon'], 0, 4 ) != 'http') $img_path = WPBC_PLUGIN_URL . '/assets/img/' . $params['icon'];
1564 else $img_path = $params['icon'];
1565
1566 ?><img class="menuicons" src="<?php echo $img_path; ?>"><?php // Img Icon
1567
1568 } elseif ( ! empty( $params['font_icon'] ) ) {
1569
1570 ?><i class="menu_icon icon-1x <?php echo $params['font_icon']; ?>"></i>&nbsp;<?php // Font Icon
1571
1572 } ?><span
1573 class="nav-tab-text"><?php echo $params['title']; ?></span>&nbsp;<b
1574 class="caret" style="border-top-color: #333333 !important;"></b></a>
1575 <ul class="dropdown-menu" role="menu" style="<?php echo ( ( $params['position'] == 'right' ) ? 'right:0px; left:auto;' : '' ); ?>">
1576 <?php
1577 foreach ( $params['items'] as $items ) {
1578 switch ( $items['type'] ) {
1579
1580 case 'divider':
1581 ?><li class="divider"></li><?php
1582 break;
1583
1584 case 'text':
1585 ?><li <?php echo wpbc_get_custom_attr( $items ); ?> ><?php echo $items['title']; ?></li><?php
1586 break;
1587
1588 default:
1589 ?><li><a <?php echo wpbc_get_custom_attr( $items ); ?> href="<?php echo $items['url']; ?>"><?php echo $items['title']; ?></a></li><?php
1590 break;
1591 }
1592 }
1593 ?>
1594 </ul>
1595 </span><?php
1596 }
1597
1598
1599
1600 ////////////////////////////////////////////////////////////////////////////////
1601 // Vertical Buttons Group
1602 ////////////////////////////////////////////////////////////////////////////////
1603
1604 /**
1605 * Devine Vertical Buttons Group
1606 *
1607 * @param array $params
1608 *
1609 * Example:
1610 $params['btn_vm_calendar'] = array(
1611 'title' => ''
1612 , 'hint' => array( 'title' => __('Calendar Overview' ,'booking') , 'position' => 'bottom' )
1613 , 'selected' => ( $selected_view_mode == 'vm_calendar' ) ? true : false
1614 , 'link' => $bk_admin_url . '&view_mode=vm_calendar'
1615 , 'icon' => ''
1616 , 'font_icon' => 'glyphicon glyphicon-calendar'
1617 );
1618
1619 */
1620 function wpbc_bs_vertical_buttons_group( $params ) {
1621
1622 ?><div role="group" class="btn-group-vertical" aria-label="..." ><?php
1623
1624 foreach ( $params as $btn_id => $btn_params ) {
1625
1626 ?><a id="<?php echo $btn_id; ?>"
1627 <?php if ( ! empty( $btn_params['hint'] ) ) { ?>
1628 title="<?php echo esc_js( $btn_params['hint']['title'] ); ?>"
1629 <?php
1630 /* data-original-title="<?php echo esc_js( $btn_params['hint'] ); ?>" */
1631 } ?>
1632 class="button button-secondary <?php
1633 echo ( $btn_params['selected'] ) ? 'active ' : '' ;
1634 echo ( ! empty( $btn_params['hint'] ) ) ? 'tooltip_' . $btn_params['hint']['position'] . ' ' : '' ;
1635 echo ( ! empty( $btn_params['css_classes'] ) ) ? $btn_params['css_classes'] . ' ' : '' ;
1636 ?>"
1637 href="<?php echo $btn_params['link']; ?>"
1638 onclick="javascript:void(0)"
1639 ><?php
1640
1641 // Icon
1642 $is_icon_not_showed = false;
1643 if ( ! empty( $btn_params['icon'] ) ) {
1644
1645 if ( substr( $btn_params['icon'], 0, 4 ) != 'http')
1646 $img_path = WPBC_PLUGIN_URL . '/assets/img/' . $btn_params['icon'];
1647 else
1648 $img_path = $btn_params['icon'];
1649
1650 ?><img class="menuicons" src="<?php echo $img_path; ?>" style="width:20px;" /><?php // IMG Icon
1651
1652 } elseif ( ! empty( $btn_params['font_icon'] ) ) {
1653
1654 ?><i class="menu_icon icon-1x <?php echo $btn_params['font_icon']; ?>"></i><?php // Font Icon
1655 } else {
1656 $is_icon_not_showed = true;
1657 }
1658
1659 // Text
1660 if ( ( ! empty( $btn_params['title'] ) ) && ( ( $is_icon_not_showed ) ) ){
1661 ?><span class="btn-group-vertical-text" >&nbsp;<?php echo esc_js( $btn_params['title'] ); ?></span><?php
1662 }
1663
1664 ?></a><?php
1665 }
1666
1667 ?></div><?php
1668
1669 }
1670
1671
1672
1673 ////////////////////////////////////////////////////////////////////////////////
1674 // Navigation Toolbar Tabs
1675 ////////////////////////////////////////////////////////////////////////////////
1676
1677 /**
1678 * Display Tab in Navigation line
1679 *
1680 * @param array $args
1681 array(
1682 'title' => '' // Title of TAB
1683 , 'hint' => array( 'title' => '', 'position' => 'bottom' ) // Hint
1684 , 'link' => 'javascript:void(0)' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
1685 , 'onclick' => '' // JS action
1686 , 'position' => '' // 'left' || 'right' || ''
1687 , 'css_classes' => '' // CSS class(es)
1688 , 'icon' => '' // Icon - link to the real PNG img
1689 , 'font_icon' => '' // CSS definition of forn Icon
1690 , 'default' => false // Is it activated by default: true || false.
1691 , 'disabled' => false // Is this sub tab deactivated: true || false.
1692 , 'checkbox' => false // false or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status', 'value' => '', 'onclick' => '' )
1693 , 'top' => true // Top or Bottom TAB: true || false.
1694 )
1695 */
1696 function wpbc_bs_display_tab( $args = array() ) {
1697
1698 $defaults = array(
1699 'top' => true,
1700 'title' => '',
1701 'hint' => '',
1702 'link' => 'javascript:void(0)',
1703 'onclick' => '',
1704 'css_classes' => '',
1705 'text_css' => '',
1706 'icon' => '',
1707 'font_icon' => '',
1708 'checkbox' => false,
1709 'disabled' => false,
1710 'default' => false
1711 );
1712
1713 $tab = wp_parse_args( $args, $defaults );
1714
1715
1716 if ( ( ! empty( $tab['hint'] ) ) && ( is_string( $tab['hint'] ) ) ) { // Compatibility with previous hint declaration
1717
1718 if ( $tab['top'] === true ) $tab['hint'] = array( 'title' => $tab['hint'], 'position' => 'top' );
1719 else $tab['hint'] = array( 'title' => $tab['hint'], 'position' => 'bottom' );
1720 }
1721
1722
1723 $html_tag = 'a';
1724
1725 if ( $tab['disabled'] ) {
1726 $tab['link'] = 'javascript:void(0)';
1727 $html_tag = 'span';
1728 }
1729
1730
1731 echo '<' , $html_tag , ' '; // Start HTML Tag
1732
1733 if ( $html_tag == 'a' ) { // Paramters for A tag
1734
1735 echo ' href="' , $tab['link'] , '" ';
1736 //echo ' title="' , esc_js( $tab['title'] ) , '" ';
1737
1738 if ( ! empty( $tab['onclick'] ) )
1739 echo ' onclick="javascript:' , $tab['onclick'] , '" ';
1740 }
1741
1742 if ( ! empty( $tab['hint'] ) ) { // Hint
1743 echo ' title="' , esc_js( $tab['hint']['title'] ) , '" ';
1744 }
1745
1746 echo ' class="nav-tab'; // CSS Classes
1747
1748 if ( $tab['top'] !== true ) echo ' wpdevelop-submenu-tab';
1749 if ( $tab['default'] ) echo ' nav-tab-active';
1750 if ( $tab['disabled'] ) echo ' wpdevelop-tab-disabled';
1751 if ( ! empty( $tab['hint'] ) ) echo ' tooltip_' , $tab['hint']['position'];
1752 if ( ! empty( $tab['position'] ) ) echo ' nav-tab-position-' , $tab['position'];
1753 if ( ! empty( $tab['hided'] ) ) echo ' hide';
1754
1755 echo ' ' , $tab['css_classes'];
1756
1757 echo '" ';
1758
1759 echo wpbc_get_custom_attr( $tab );
1760 echo '>'; // Close > for A or SPAN
1761
1762
1763 // Icon
1764 $is_icon_showed = true;
1765 if ( ! empty( $tab['icon'] ) ) {
1766
1767 if ( substr( $tab['icon'], 0, 4 ) != 'http')
1768 $img_path = WPBC_PLUGIN_URL . '/assets/img/' . $tab['icon'];
1769 else
1770 $img_path = $tab['icon'];
1771
1772 ?><img class="menuicons" src="<?php echo $img_path; ?>" style="width:20px;" /><?php // IMG Icon
1773
1774 } elseif ( ! empty( $tab['font_icon'] ) ) {
1775
1776 ?><i class="menu_icon icon-1x <?php echo $tab['font_icon']; ?>"></i><?php // Font Icon
1777 } else {
1778 $is_icon_showed = false;
1779 }
1780
1781 // Text
1782
1783 ?><span class="<?php echo ( $is_icon_showed ) ? 'nav-tab-text' : ''; ?>" style="<?php echo esc_attr( $tab['text_css'] ); ?>" ><?php
1784 if ( ! empty( $tab['title'] ) ) {
1785 echo ( $is_icon_showed ) ? '&nbsp;&nbsp;' : '';
1786 }
1787 echo $tab['title'];
1788 ?></span><?php
1789
1790 // C h e c k b o x
1791 if ( $tab['checkbox'] !== false ) {
1792 ?><input type="checkbox"
1793 <?php if ( $tab['checkbox']['checked'] ) echo ' checked="CHECKED" '; ?>
1794 name="<?php echo $tab['checkbox']['name']; ?>_dublicated"
1795 id="<?php echo $tab['checkbox']['name']; ?>_dublicated"
1796 value="<?php echo ( isset( $tab['checkbox']['value'] ) ? $tab['checkbox']['value'] : '' ); ?>"
1797 onchange="javascript: <?php if ( isset( $tab['checkbox']['onclick'] ) ) {
1798 echo $tab['checkbox']['onclick'];
1799 } else {
1800 ?>if ( jQuery('#<?php echo $tab['checkbox']['name']; ?>').length > 0 ) { document.getElementById('<?php echo $tab['checkbox']['name']; ?>').checked = this.checked; }<?php
1801 }
1802 ?>"
1803 /><?php
1804 }
1805
1806
1807 echo '</' , $html_tag , '>';
1808
1809
1810 if (
1811 ( isset( $tab['top'] ) ) && ( $tab['top'] )
1812 && ( isset( $tab['position'] ) ) && ( $tab['position'] !== 'right' ) //FixIn: 6.0.1.13
1813 )
1814 echo '&nbsp;';
1815 }
1816
1817 function wpbc_bs_toolbar_tabs_html_container_start() {
1818
1819 ?>
1820 <div class="wpdvlp-top-tabs">
1821 <div class="wpdvlp-tabs-wrapper">
1822 <div class="nav-tabs" ><?php // T O P T A B S
1823 }
1824
1825 function wpbc_bs_toolbar_tabs_html_container_end() {
1826
1827 ?></div><!-- nav-tabs -->
1828 </div><!-- wpdvlp-tabs-wrapper -->
1829 </div><!-- wpdvlp-top-tabs --><?php
1830 }
1831
1832 function wpbc_bs_toolbar_sub_html_container_start() {
1833 // S U B T A B S or U I elements
1834 ?><div class="wpdvlp-sub-tabs">
1835 <div class="wpdvlp-tabs-wrapper">
1836 <div class="nav-tabs"><?php
1837 }
1838
1839 function wpbc_bs_toolbar_sub_html_container_end() {
1840
1841 ?><div class="clear"></div>
1842 </div><!-- nav-tabs -->
1843 </div><!-- wpdvlp-tabs-wrapper -->
1844 </div><!-- wpdvlp-sub-tabs --><?php
1845 }
1846
1847 // FlexTable :: Tabs in Flex Table for switching view of Table content
1848 function wpbc_flextable_header_tabs_html_container_start() {
1849
1850 ?><span class="wpbc_flextable_header_tabs">
1851 <div class="wpdvlp-top-tabs"><?php
1852
1853 }
1854
1855 function wpbc_flextable_header_tabs_html_container_end() {
1856
1857 ?></div><!-- wpdvlp-top-tabs -->
1858 </span><!-- wpdevelop wpbc_flextable_header_tabs --><?php
1859 }
1860
1861
1862 /**
1863 * Get HTML for Open / Close [+/-] Links for help sections
1864 *
1865 * @param $link_title string
1866 * @param $is_open bool
1867 * @param $params array
1868 *
1869 * @return false|string
1870 *
1871 * Example 1:
1872 * wpbc_get_open_close_link__container_start_html( array(
1873 * 'title' => __('Standard Shortcodes' ,'booking'),
1874 * 'is_open' => true,
1875 * 'params' => array(
1876 * 'container_attr' => array( 'style' => 'font-weight:600;' ),
1877 * 'content_attr' => array( 'style' => 'font-weight:400;display:block;padding: 0px 5px;margin: 0;background: #fff;' )
1878 * )));
1879 *
1880 * Example 2:
1881 * wpbc_get_open_close_link__container_start_html( array(
1882 * 'title' => __('Cost Hints' ,'booking'),
1883 * 'params' => array( 'container_class' => 'wpbc_deprected_help_container' )
1884 * ));
1885 */
1886 function wpbc_get_open_close_link__container_start_html( $params = array() ) {
1887
1888 $defaults = array(
1889 'title' => ''
1890 , 'is_open' => false
1891 , 'params' => array()
1892 );
1893 $params = wp_parse_args( $params, $defaults );
1894
1895 $defaults = array(
1896 'container_class' => '',
1897 'container_attr' => array(),
1898 'link_class' => '',
1899 'link_attr' => array(),
1900 'content_class' => '',
1901 'content_attr' => array()
1902 );
1903 $params['params'] = wp_parse_args( $params['params'], $defaults );
1904
1905 ob_start();
1906
1907 $params['params']['container_attr'] = WPBC_Settings_API::get_custom_attr_static( array( 'attr' => $params['params']['container_attr'] ) );
1908 $params['params']['link_attr'] = WPBC_Settings_API::get_custom_attr_static( array( 'attr' => $params['params']['link_attr'] ) );
1909 $params['params']['content_attr'] = WPBC_Settings_API::get_custom_attr_static( array( 'attr' => $params['params']['content_attr'] ) );
1910
1911 ?><div class="wpbc_container_open_or_closed <?php echo ( $params['is_open'] ? '':' wpbc_container_closed ' );
1912 echo esc_attr( $params['params']['container_class'] ); ?>" <?php echo $params['params']['container_attr']; ?>><?php
1913
1914 ?><a href="javascript:void(0)" class="wpbc_container_open_or_closed__link <?php echo esc_attr( $params['params']['link_class'] ); ?>" <?php echo $params['params']['link_attr']; ?>><?php
1915 echo $params['title'];
1916 ?></a><?php
1917 ?><div class="wpbc_container_open_or_closed__content <?php echo esc_attr( $params['params']['content_class'] ); ?>"
1918 <?php echo ( $params['is_open'] ? '':' style="display:none;" ' ); ?>
1919 <?php echo $params['params']['content_attr']; ?>><?php
1920
1921 return ob_get_clean();
1922 }
1923
1924 /**
1925 * Get HTML for Open / Close [+/-] Links for help sections
1926 *
1927 * @return false|string
1928 */
1929 function wpbc_get_open_close_link__container_end_html() {
1930
1931 ob_start();
1932
1933 ?></div><!-- wpbc_container_open_or_closed__content -->
1934 </div><!-- wpbc_container_open_or_closed --><?php
1935
1936 return ob_get_clean();
1937 }
1938
1939
1940 ////////////////////////////////////////////////////////////////////////////////
1941 // HTML sections and groups
1942 ////////////////////////////////////////////////////////////////////////////////
1943
1944 /** Clear Div */
1945 function wpbc_clear_div() {
1946 ?><div class="clear"></div><?php
1947 }
1948
1949
1950
1951 ////////////////////////////////////////////////////////////////////////////////
1952 // JS & CSS
1953 ////////////////////////////////////////////////////////////////////////////////
1954 /** Tooltips JavaScript functions */
1955 function wpbc_bs_javascript_tooltips() {
1956
1957 ?><span id="wpbc_tooltips_container"></span><?php
1958 //FixIn: 7.0.1.10
1959 ?><script type="text/javascript">
1960
1961 function wpbc_define_tippy_tooltips( parent_class ){
1962
1963 if ( 'function' !== typeof( wpbc_tippy ) ){
1964 alert( 'WPBC Error. JavaScript library "wpbc_tippy" was not defined.' );
1965 return false;
1966 }
1967
1968 //FixIn: 9.0.1.1
1969 /**
1970 * Get Title to show in tooltip.
1971 * By default getting text from 'data-original-title' attribute, if not exist,
1972 * then checking 'title' attribute and replacing it by 'data-original-title'
1973 *
1974 * @param reference - Dom element
1975 * @returns string
1976 */
1977 function wpbc_get_tippy_tooltip_title_text( reference ){
1978 var text2show = reference.getAttribute( 'data-original-title' );
1979 if ( null == text2show ){
1980 text2show = reference.getAttribute( 'title' );
1981 jQuery( reference ).attr( "data-original-title", jQuery( reference ).attr( "title" ) );
1982 jQuery( reference ).removeAttr( "title" );
1983 }
1984 return text2show;
1985 }
1986
1987 if ( undefined == parent_class ){
1988 parent_class = '';
1989 }
1990
1991 wpbc_tippy( parent_class + '.tooltip_top', {
1992 content( reference ){
1993 return wpbc_get_tippy_tooltip_title_text( reference );
1994 },
1995 placement: 'top-start',
1996 } );
1997 wpbc_tippy( parent_class + '.tooltip_bottom', {
1998 content( reference ){
1999 return wpbc_get_tippy_tooltip_title_text( reference );
2000 },
2001 placement: 'bottom-start',
2002 } );
2003 wpbc_tippy( parent_class + '.tooltip_bottom', {
2004 content( reference ){
2005 return wpbc_get_tippy_tooltip_title_text( reference );
2006 },
2007 placement: 'bottom-start',
2008 } );
2009 wpbc_tippy( parent_class + '.tooltip_right', {
2010 content( reference ){
2011 return wpbc_get_tippy_tooltip_title_text( reference );
2012 },
2013 placement: 'right',
2014 } );
2015 wpbc_tippy( parent_class + '.tooltip_left', {
2016 content( reference ){
2017 return wpbc_get_tippy_tooltip_title_text( reference );
2018 },
2019 placement: 'left-start',
2020 } );
2021
2022 return true;
2023 }
2024
2025 jQuery( document ).ready( function (){
2026 wpbc_define_tippy_tooltips( '' );
2027 } );
2028 </script><?php
2029 }
2030
2031
2032 /** Popover JavaScript functions */
2033 function wpbc_bs_javascript_popover() {
2034
2035 ?><script type="text/javascript">
2036
2037 function wpbc_define_tippy_popover(){
2038
2039 if ( 'function' !== typeof( wpbc_tippy ) ) {
2040 alert( 'WPBC Error. wpbc_tippy was not defined.' );
2041 return false;
2042 }
2043
2044 //FixIn: 9.0.1.1
2045 wpbc_tippy( '.popover_bottom.popover_click', {
2046 content( reference ){
2047 var popover_title = reference.getAttribute( 'data-original-title' );
2048 var popover_content = reference.getAttribute( 'data-content' );
2049 return '<div class="popover popover_tippy">'
2050 + '<div class="popover-close"><a href="javascript:void(0)" onclick="javascript:this.parentElement.parentElement.parentElement.parentElement.parentElement._tippy.hide();" >&times;</a></div>'
2051 // + '<div class="popover-title">'
2052 // + popover_title
2053 // + '</div>'
2054 // + '<div class="popover-content">'
2055 + popover_content
2056 //+ '</div>'
2057 + '</div>';
2058 },
2059 allowHTML : true,
2060 trigger : 'manual',
2061 interactive : true,
2062 hideOnClick : false,
2063 interactiveBorder: 10,
2064 maxWidth : 550,
2065 theme : 'wpbc-tippy-popover',
2066 placement : 'bottom-start',
2067 touch: ['hold', 500], // 500ms delay
2068 } );
2069
2070 // Define ability to open / close popover by clicking on link
2071 jQuery( '.popover_bottom.popover_click' ).on( 'click', function (){
2072 if( this._tippy.state.isVisible ) {
2073 this._tippy.hide();
2074 } else {
2075 this._tippy.show();
2076 }
2077 });
2078 }
2079
2080 <?php echo wpbc_jq_ready_start(); //FixIn: 10.1.3.7 ?>
2081 wpbc_define_tippy_popover(); //FixIn: 9.0.1.1
2082 <?php echo wpbc_jq_ready_end(); ?>
2083 </script><?php
2084 }
2085
2086
2087
2088 ////////////////////////////////////////////////////////////////////////////////
2089 // S U P P O R T
2090 ////////////////////////////////////////////////////////////////////////////////
2091
2092 /**
2093 * Get custom atrributes for HTML elements
2094 *
2095 * @param array $field
2096 * @return type
2097 */
2098 function wpbc_get_custom_attr( $field ) {
2099
2100 $attributes = array();
2101
2102 if ( ! empty( $field['attr'] ) && is_array( $field['attr'] ) ) {
2103
2104 foreach ( $field['attr'] as $attr => $attr_v ) {
2105 $attributes[] = esc_attr( $attr ) . '="' . esc_attr( $attr_v ) . '"';
2106 }
2107 }
2108
2109 return implode( ' ', $attributes );
2110 }