PluginProbe
Booking Calendar / 11.8
Booking Calendar v11.8
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
booking / includes / _functions / admin-cost-correction.php

admin-cost-correction.php in Booking Calendar 11.8, at includes/_functions/admin-cost-correction.php

103 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shared administrator cost-correction control.
4 *
5 * @package Booking Calendar
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Render an optional exact-total control for an authorized administrator workflow.
14 *
15 * The control deliberately renders only when the Business Small cost engine is
16 * available. It does not submit itself because both supported inspectors live
17 * outside the native Booking Form. Their page adapters copy a non-empty value
18 * into the dedicated booking-create request parameter, which is authorized and
19 * validated again by the shared server save boundary.
20 *
21 * @param array $args {
22 * Control presentation arguments supplied by trusted plugin code.
23 *
24 * @type string $input_id Unique HTML input ID.
25 * @type int $resource_id Optional Booking resource used for its currency symbol.
26 * @type string $wrapper_class Wrapper CSS classes.
27 * @type string $label_class Label CSS classes.
28 * @type string $control_class Control-container CSS classes.
29 * @type string $input_class Number-input CSS classes.
30 * @type string $help_class Help-paragraph CSS classes.
31 * @type string $label Translated field label.
32 * @type string $placeholder Translated empty-value placeholder.
33 * @type string $suffix Translated suffix displayed after the number.
34 * @type string $help Translated workflow explanation.
35 * }
36 *
37 * @return void
38 */
39 function wpbc_render_admin_cost_correction_control( $args = array() ) {
40
41 if ( ! class_exists( 'wpdev_bk_biz_s' ) ) {
42 return;
43 }
44
45 $args = wp_parse_args(
46 $args,
47 array(
48 'input_id' => 'wpbc_admin_cost_correction',
49 'resource_id' => 0,
50 'wrapper_class' => '',
51 'label_class' => '',
52 'control_class' => '',
53 'input_class' => 'inspector__input',
54 'help_class' => 'description',
55 'label' => __( 'Cost correction', 'booking' ),
56 'placeholder' => __( 'Calculated cost', 'booking' ),
57 'suffix' => __( 'total', 'booking' ),
58 'help' => __( 'Leave the number empty to use the calculated cost. Enter an exact total to replace the final cost.', 'booking' ),
59 )
60 );
61
62 $input_id = sanitize_key( $args['input_id'] );
63 $resource_id = absint( $args['resource_id'] );
64 $currency_symbol = $resource_id > 0 && function_exists( 'wpbc_get_currency_symbol_for_user' )
65 ? wpbc_get_currency_symbol_for_user( $resource_id )
66 : ( function_exists( 'wpbc_get_currency_symbol' ) ? wpbc_get_currency_symbol() : '' );
67 $currency_symbol = html_entity_decode( wp_strip_all_tags( (string) $currency_symbol ), ENT_QUOTES, get_bloginfo( 'charset' ) );
68 ?>
69 <div class="wpbc_admin_cost_correction <?php echo esc_attr( $args['wrapper_class'] ); ?>" data-wpbc-admin-cost-correction="1">
70 <label for="<?php echo esc_attr( $input_id ); ?>" class="<?php echo esc_attr( $args['label_class'] ); ?>"><?php echo esc_html( $args['label'] ); ?></label>
71 <div class="<?php echo esc_attr( $args['control_class'] ); ?>">
72 <div class="wpbc_admin_cost_correction__number_control">
73 <div class="wpbc_admin_cost_correction__number_input_row">
74 <?php if ( '' !== $currency_symbol ) : ?>
75 <span class="wpbc_admin_cost_correction__number_prefix"><?php echo esc_html( $currency_symbol ); ?></span>
76 <?php endif; ?>
77 <input id="<?php echo esc_attr( $input_id ); ?>"
78 type="number"
79 class="<?php echo esc_attr( $args['input_class'] ); ?>"
80 value=""
81 min="0"
82 max="1000000000"
83 step="0.01"
84 inputmode="decimal"
85 placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>"
86 data-wpbc-admin-cost-correction-value="1" />
87 <span class="wpbc_admin_cost_correction__number_suffix"><?php echo esc_html( $args['suffix'] ); ?></span>
88 </div>
89 <input type="range"
90 class="wpbc_admin_cost_correction__number_slider"
91 min="0"
92 max="1000"
93 step="1"
94 value="0"
95 aria-label="<?php echo esc_attr( $args['label'] ); ?>"
96 data-wpbc-admin-cost-correction-range="1" />
97 </div>
98 <p class="<?php echo esc_attr( $args['help_class'] ); ?>"><?php echo esc_html( $args['help'] ); ?></p>
99 </div>
100 </div>
101 <?php
102 }
103