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