PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.1.21
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.1.21
2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 2.0.22 All 55 releases
booking-manager / core / any / admin-bs-ui.php

admin-bs-ui.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.1.21, at core/any/admin-bs-ui.php

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