PluginProbe
Booking Calendar / 10.15.6
Booking Calendar v10.15.6
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
booking / includes / elementor-booking-form / controls / elementor_custom_form.php

elementor_custom_form.php in Booking Calendar 10.15.6, at includes/elementor-booking-form/controls/elementor_custom_form.php

148 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 /**
4 * Elementor WPBC_Elementor_Custom_Form_Selection_Control control.
5 *
6 * A control for displaying a select field with the ability to choose booking_custom_forms.
7 *
8 * @since 1.0.0
9 */
10 class WPBC_Elementor_Custom_Form_Selection_Control extends \Elementor\Base_Data_Control {
11
12 /**
13 * Get custom_form control type.
14 *
15 * Retrieve the control type, in this case `custom_form`.
16 *
17 * @since 1.0.0
18 * @access public
19 * @return string Control type.
20 */
21 public function get_type(): string {
22 return 'wpbc_custom_form_selection';
23 }
24
25 /**
26 * Get booking_custom_forms.
27 *
28 * Retrieve all the available booking_custom_forms.
29 *
30 * @since 1.0.0
31 * @access public
32 * @static
33 * @return array Available booking_custom_forms.
34 */
35 public static function get_booking_custom_forms(): array {
36
37 $is_bfb_enabled = (bool) WPBC_Frontend_Settings::is_bfb_enabled( null );
38 if ( $is_bfb_enabled ) {
39 $custom_forms_arr_sorted = WPBC_FE_Custom_Form_Helper::wpbc_bfb__custom_booking_forms_list__selectbox_html__for_elementor();
40 } else {
41 $custom_forms_arr_sorted = wpbc_toolbar__get_custom_forms__options_for_selection();
42 }
43
44 $sorted_options_list = array();
45
46 foreach ( $custom_forms_arr_sorted as $slug => $form_item ) {
47 if ( is_array( $form_item ) ) {
48 if ( isset( $form_item['optgroup'] ) ) {
49 $sorted_options_list[] = $form_item;
50 } else {
51 // Legacy skins with attributes: 'style=>'color:#ccc;' .
52 $form_item['slug'] = $slug;
53 $sorted_options_list[] = $form_item;
54 }
55 } else {
56 $sorted_options_list[] = array(
57 'slug' => $slug,
58 'title' => $form_item,
59 );
60 }
61 }
62
63 return $sorted_options_list;
64 }
65
66 /**
67 * Get custom_form control default settings.
68 *
69 * Retrieve the default settings of the custom_form control. Used to return
70 * the default settings while initializing the custom_form control.
71 *
72 * @since 1.0.0
73 * @access protected
74 * @return array Currency control default settings.
75 */
76 protected function get_default_settings(): array {
77 return [
78 'booking_custom_forms' => self::get_booking_custom_forms()
79 ];
80 }
81
82 /**
83 * Get custom_form control default value.
84 *
85 * Retrieve the default value of the custom_form control. Used to return the
86 * default value while initializing the control.
87 *
88 * @since 1.0.0
89 * @access public
90 * @return array Currency control default value.
91 */
92 public function get_default_value(): string {
93
94 $booking_custom_forms_arr = self::get_booking_custom_forms();
95
96 foreach ( $booking_custom_forms_arr as $index => $custom_form_arr ) {
97 return $custom_form_arr['slug'];
98 }
99 return 'standard';
100 }
101
102
103 /**
104 * Render custom_form control output in the editor.
105 *
106 * Used to generate the control HTML in the editor using Underscore JS
107 * template. The variables for the class are available using `data` JS
108 * object.
109 *
110 * @since 1.0.0
111 * @access public
112 */
113 public function content_template(): void {
114 $control_uid = $this->get_control_uid();
115 ?>
116 <div class="elementor-control-field elementor-control-type-select">
117
118 <# if ( data.label ) {#>
119 <label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{ data.label }}}</label>
120 <# } #>
121
122 <div class="elementor-control-input-wrapper">
123 <select id="<?php echo esc_attr( $control_uid ); ?>" data-setting="{{ data.name }}">
124 <# _.each( data.booking_custom_forms, function( custom_form_arr, custom_form_index ) {
125 if ( custom_form_arr['optgroup'] ) { // OPTGROUP
126
127 if ( ! custom_form_arr['close'] ) {
128 #><optgroup label="{{{custom_form_arr['title']}}}"><#
129 } else {
130 #></optgroup><#
131 }
132
133 } else {
134 #><option value="{{ custom_form_arr['slug'] }}" >{{{ custom_form_arr['title'] }}}</option><#
135 }
136 } ); #>
137 </select>
138 </div>
139
140 </div>
141 <# if ( data.description ) { #>
142 <div class="elementor-control-field-description">{{{ data.description }}}</div>
143 <# } #>
144 <?php
145 }
146
147 }
148