| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @category Simple Booking Form Setup |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site https://wpbookingcalendar.com/ |
| 8 |
* @email info@wpbookingcalendar.com |
| 9 |
* |
| 10 |
* @modified 2024-08-16 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* Get 'Blank Visual Structure' of booking form |
| 18 |
* |
| 19 |
* It can be imported from very old Free version, if such options exist in plugin DB, otherwise it is blank template |
| 20 |
* |
| 21 |
* @return array |
| 22 |
*/ |
| 23 |
function wpbc_simple_form__visual__get_default_form() { |
| 24 |
|
| 25 |
$visual_form_structure = array(); |
| 26 |
|
| 27 |
// Calendar |
| 28 |
$visual_form_structure[] = array( |
| 29 |
'type' => 'calendar', |
| 30 |
'name' => 'calendar', |
| 31 |
'obligatory' => 'On', |
| 32 |
'if_exist_required' => 'On', |
| 33 |
'label' => '' //__('Select date', 'booking') |
| 34 |
); |
| 35 |
// Time - Slots |
| 36 |
$time_slots_arr = array( '09:00 - 10:00', '10:00 - 11:00', '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00', |
| 37 |
'14:00 - 15:00', '15:00 - 16:00', '16:00 - 17:00', '17:00 - 18:00', '18:00 - 19:00' |
| 38 |
); |
| 39 |
$time_slots_str = ''; |
| 40 |
foreach ( $time_slots_arr as $time_slot_v ) { |
| 41 |
$time_slots_str .= wpbc_time_slot_in_format( $time_slot_v ) . '@@' . $time_slot_v . "\r\n"; |
| 42 |
} |
| 43 |
$time_slots_str .= 'Full Day@@00:00 - 24:00'; |
| 44 |
|
| 45 |
$visual_form_structure[] = array( |
| 46 |
'type' => 'selectbox', |
| 47 |
'name' => 'rangetime', |
| 48 |
'obligatory' => 'Off', |
| 49 |
'active' => 'On', |
| 50 |
'required' => 'On', |
| 51 |
'if_exist_required' => 'On', |
| 52 |
'label' => __( 'Time Slots', 'booking' ), |
| 53 |
'value' => $time_slots_str |
| 54 |
); |
| 55 |
// First Name |
| 56 |
$visual_form_structure[] = array( |
| 57 |
'type' => 'text', |
| 58 |
'name' => 'name', |
| 59 |
'obligatory' => 'Off', |
| 60 |
'active' => empty( get_bk_option( 'booking_form_field_active1' ) ) ? 'On' : get_bk_option( 'booking_form_field_active1' ), |
| 61 |
'required' => empty( get_bk_option( 'booking_form_field_required1' ) ) ? 'On' : get_bk_option( 'booking_form_field_required1' ), |
| 62 |
'label' => empty( get_bk_option( 'booking_form_field_label1' ) ) ? __( 'First Name', 'booking' ) : get_bk_option( 'booking_form_field_label1' ) |
| 63 |
); |
| 64 |
// Second Name |
| 65 |
$visual_form_structure[] = array( |
| 66 |
'type' => 'text', |
| 67 |
'name' => 'secondname', |
| 68 |
'obligatory' => 'Off', |
| 69 |
'active' => empty( get_bk_option( 'booking_form_field_active2' ) ) ? 'On' : get_bk_option( 'booking_form_field_active2' ), |
| 70 |
'required' => empty( get_bk_option( 'booking_form_field_required2' ) ) ? 'On' : get_bk_option( 'booking_form_field_required2' ), |
| 71 |
'label' => empty( get_bk_option( 'booking_form_field_label2' ) ) ? __( 'Second Name', 'booking' ) : get_bk_option( 'booking_form_field_label2' ) |
| 72 |
); |
| 73 |
// Email |
| 74 |
$visual_form_structure[] = array( |
| 75 |
'type' => 'email', |
| 76 |
'name' => 'email', |
| 77 |
'obligatory' => 'On', |
| 78 |
'active' => 'On', |
| 79 |
'required' => 'On', |
| 80 |
'label' => empty( get_bk_option( 'booking_form_field_label3' ) ) ? __( 'Email', 'booking' ) : get_bk_option( 'booking_form_field_label3' ) |
| 81 |
); |
| 82 |
// Visitors |
| 83 |
$visual_form_structure[] = array( |
| 84 |
'type' => 'selectbox', |
| 85 |
'name' => 'visitors', |
| 86 |
'obligatory' => 'Off', |
| 87 |
'active' => empty( get_bk_option( 'booking_form_field_active6' ) ) ? 'On' : get_bk_option( 'booking_form_field_active6' ), |
| 88 |
'required' => empty( get_bk_option( 'booking_form_field_required6' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required6' ), |
| 89 |
'label' => empty( get_bk_option( 'booking_form_field_label6' ) ) ? __( 'Visitors', 'booking' ) : get_bk_option( 'booking_form_field_label6' ), |
| 90 |
'value' => (empty( get_bk_option( 'booking_form_field_values6' ) ) |
| 91 |
? ( '1' . "\r\n" . '2' . "\r\n" . '3' . "\r\n" . '4' ) |
| 92 |
: get_bk_option( 'booking_form_field_values6' ) ) |
| 93 |
); |
| 94 |
// Phone |
| 95 |
$visual_form_structure[] = array( |
| 96 |
'type' => 'text', |
| 97 |
'name' => 'phone', |
| 98 |
'obligatory' => 'Off', |
| 99 |
'active' => empty( get_bk_option( 'booking_form_field_active4' ) ) ? 'On' : get_bk_option( 'booking_form_field_active4' ), |
| 100 |
'required' => empty( get_bk_option( 'booking_form_field_required4' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required4' ), |
| 101 |
'label' => empty( get_bk_option( 'booking_form_field_label4' ) ) ? __( 'Phone', 'booking' ) : get_bk_option( 'booking_form_field_label4' ) |
| 102 |
); |
| 103 |
// Details - textarea |
| 104 |
$visual_form_structure[] = array( |
| 105 |
'type' => 'textarea', |
| 106 |
'name' => 'details', |
| 107 |
'obligatory' => 'Off', |
| 108 |
'active' => empty( get_bk_option( 'booking_form_field_active5' ) ) ? 'On' : get_bk_option( 'booking_form_field_active5' ), |
| 109 |
'required' => empty( get_bk_option( 'booking_form_field_required5' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required5' ), |
| 110 |
'label' => empty( get_bk_option( 'booking_form_field_label5' ) ) ? __( 'Details', 'booking' ) : get_bk_option( 'booking_form_field_label5' ) |
| 111 |
); |
| 112 |
// CAPTCHA |
| 113 |
$visual_form_structure[] = array( |
| 114 |
'type' => 'captcha', |
| 115 |
'name' => 'captcha', |
| 116 |
'obligatory' => 'Off', |
| 117 |
'active' => ( get_bk_option( 'booking_is_use_captcha' ) == 'On' ) ? 'On' : 'Off', |
| 118 |
'required' => 'On', |
| 119 |
'if_exist_required' => 'On', |
| 120 |
'label' => '' |
| 121 |
); |
| 122 |
// Submit |
| 123 |
$visual_form_structure[] = array( |
| 124 |
'type' => 'submit', |
| 125 |
'name' => 'submit', |
| 126 |
'obligatory' => 'On', |
| 127 |
'active' => 'On', |
| 128 |
'required' => 'On', |
| 129 |
'if_exist_required' => 'On', |
| 130 |
'label' => empty( get_bk_option( 'booking_send_button_title' ) ) ? __( 'Send', 'booking' ) : get_bk_option( 'booking_send_button_title' ) |
| 131 |
); |
| 132 |
return $visual_form_structure; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
/** |
| 137 |
* Get 'Blank Visual Structure' of booking form |
| 138 |
* |
| 139 |
* It can be imported from very old Free version, if such options exist in plugin DB, otherwise it is blank template |
| 140 |
* |
| 141 |
* @return array |
| 142 |
*/ |
| 143 |
function wpbc_simple_form__visual__get_default_form__times_30min() { |
| 144 |
|
| 145 |
$visual_form_structure = array(); |
| 146 |
|
| 147 |
// Calendar |
| 148 |
$visual_form_structure[] = array( |
| 149 |
'type' => 'calendar', |
| 150 |
'name' => 'calendar', |
| 151 |
'obligatory' => 'On', |
| 152 |
'if_exist_required' => 'On', |
| 153 |
'label' => __('Select date', 'booking') |
| 154 |
); |
| 155 |
// Time - Slots |
| 156 |
$time_slots_arr = array( '09:00 - 09:30', '09:30 - 10:00', '10:00 - 10:30', '10:30 - 11:00', '11:00 - 11:30', '11:30 - 12:00', |
| 157 |
'12:00 - 12:30', '12:30 - 13:00', '13:00 - 13:30', '13:30 - 14:00', '14:00 - 14:30', '14:30 - 15:00', |
| 158 |
'15:00 - 15:30', '15:30 - 16:00', '16:00 - 16:30', '16:30 - 17:00', '17:00 - 17:30', '17:30 - 18:00' |
| 159 |
); |
| 160 |
$formated_times_arr = []; |
| 161 |
foreach ( $time_slots_arr as $time_slot_v ) { |
| 162 |
$formated_times_arr[]= wpbc_time_slot_in_format( $time_slot_v ) . '@@' . $time_slot_v; // . "\r\n"; |
| 163 |
} |
| 164 |
$time_slots_str = implode( "\r\n", $formated_times_arr ); |
| 165 |
//$time_slots_str .= 'Full Day@@00:00 - 24:00'; |
| 166 |
|
| 167 |
$visual_form_structure[] = array( |
| 168 |
'type' => 'selectbox', |
| 169 |
'name' => 'rangetime', |
| 170 |
'obligatory' => 'Off', |
| 171 |
'active' => 'On', |
| 172 |
'required' => 'On', |
| 173 |
'if_exist_required' => 'On', |
| 174 |
'label' => __('Select Time', 'booking'), //__( 'Time Slots', 'booking' ), |
| 175 |
'value' => $time_slots_str |
| 176 |
); |
| 177 |
// First Name |
| 178 |
$visual_form_structure[] = array( |
| 179 |
'type' => 'text', |
| 180 |
'name' => 'name', |
| 181 |
'obligatory' => 'Off', |
| 182 |
'active' => empty( get_bk_option( 'booking_form_field_active1' ) ) ? 'On' : get_bk_option( 'booking_form_field_active1' ), |
| 183 |
'required' => empty( get_bk_option( 'booking_form_field_required1' ) ) ? 'On' : get_bk_option( 'booking_form_field_required1' ), |
| 184 |
'label' => empty( get_bk_option( 'booking_form_field_label1' ) ) ? __( 'First Name', 'booking' ) : get_bk_option( 'booking_form_field_label1' ) |
| 185 |
); |
| 186 |
// Second Name |
| 187 |
$visual_form_structure[] = array( |
| 188 |
'type' => 'text', |
| 189 |
'name' => 'secondname', |
| 190 |
'obligatory' => 'Off', |
| 191 |
'active' => empty( get_bk_option( 'booking_form_field_active2' ) ) ? 'On' : get_bk_option( 'booking_form_field_active2' ), |
| 192 |
'required' => empty( get_bk_option( 'booking_form_field_required2' ) ) ? 'On' : get_bk_option( 'booking_form_field_required2' ), |
| 193 |
'label' => empty( get_bk_option( 'booking_form_field_label2' ) ) ? __( 'Second Name', 'booking' ) : get_bk_option( 'booking_form_field_label2' ) |
| 194 |
); |
| 195 |
// Email |
| 196 |
$visual_form_structure[] = array( |
| 197 |
'type' => 'email', |
| 198 |
'name' => 'email', |
| 199 |
'obligatory' => 'On', |
| 200 |
'active' => 'On', |
| 201 |
'required' => 'On', |
| 202 |
'label' => empty( get_bk_option( 'booking_form_field_label3' ) ) ? __( 'Email', 'booking' ) : get_bk_option( 'booking_form_field_label3' ) |
| 203 |
); |
| 204 |
// Visitors |
| 205 |
$visual_form_structure[] = array( |
| 206 |
'type' => 'selectbox', |
| 207 |
'name' => 'visitors', |
| 208 |
'obligatory' => 'Off', |
| 209 |
'active' => empty( get_bk_option( 'booking_form_field_active6' ) ) ? 'On' : get_bk_option( 'booking_form_field_active6' ), |
| 210 |
'required' => empty( get_bk_option( 'booking_form_field_required6' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required6' ), |
| 211 |
'label' => empty( get_bk_option( 'booking_form_field_label6' ) ) ? __( 'Visitors', 'booking' ) : get_bk_option( 'booking_form_field_label6' ), |
| 212 |
'value' => (empty( get_bk_option( 'booking_form_field_values6' ) ) |
| 213 |
? ( '1' . "\r\n" . '2' . "\r\n" . '3' . "\r\n" . '4' ) |
| 214 |
: get_bk_option( 'booking_form_field_values6' ) ) |
| 215 |
); |
| 216 |
// Phone |
| 217 |
$visual_form_structure[] = array( |
| 218 |
'type' => 'text', |
| 219 |
'name' => 'phone', |
| 220 |
'obligatory' => 'Off', |
| 221 |
'active' => empty( get_bk_option( 'booking_form_field_active4' ) ) ? 'On' : get_bk_option( 'booking_form_field_active4' ), |
| 222 |
'required' => empty( get_bk_option( 'booking_form_field_required4' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required4' ), |
| 223 |
'label' => empty( get_bk_option( 'booking_form_field_label4' ) ) ? __( 'Phone', 'booking' ) : get_bk_option( 'booking_form_field_label4' ) |
| 224 |
); |
| 225 |
// Details - textarea |
| 226 |
$visual_form_structure[] = array( |
| 227 |
'type' => 'textarea', |
| 228 |
'name' => 'details', |
| 229 |
'obligatory' => 'Off', |
| 230 |
'active' => empty( get_bk_option( 'booking_form_field_active5' ) ) ? 'On' : get_bk_option( 'booking_form_field_active5' ), |
| 231 |
'required' => empty( get_bk_option( 'booking_form_field_required5' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required5' ), |
| 232 |
'label' => empty( get_bk_option( 'booking_form_field_label5' ) ) ? __( 'Details', 'booking' ) : get_bk_option( 'booking_form_field_label5' ) |
| 233 |
); |
| 234 |
// CAPTCHA |
| 235 |
$visual_form_structure[] = array( |
| 236 |
'type' => 'captcha', |
| 237 |
'name' => 'captcha', |
| 238 |
'obligatory' => 'Off', |
| 239 |
'active' => ( get_bk_option( 'booking_is_use_captcha' ) == 'On' ) ? 'On' : 'Off', |
| 240 |
'required' => 'On', |
| 241 |
'if_exist_required' => 'On', |
| 242 |
'label' => '' |
| 243 |
); |
| 244 |
// Submit |
| 245 |
$visual_form_structure[] = array( |
| 246 |
'type' => 'submit', |
| 247 |
'name' => 'submit', |
| 248 |
'obligatory' => 'On', |
| 249 |
'active' => 'On', |
| 250 |
'required' => 'On', |
| 251 |
'if_exist_required' => 'On', |
| 252 |
'label' => empty( get_bk_option( 'booking_send_button_title' ) ) ? __( 'Send', 'booking' ) : get_bk_option( 'booking_send_button_title' ) |
| 253 |
); |
| 254 |
return $visual_form_structure; |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
/** |
| 259 |
* Get 'Blank Visual Structure' of booking form |
| 260 |
* |
| 261 |
* It can be imported from very old Free version, if such options exist in plugin DB, otherwise it is blank template |
| 262 |
* |
| 263 |
* @return array |
| 264 |
*/ |
| 265 |
function wpbc_simple_form__visual__get_default_form__without_times() { |
| 266 |
|
| 267 |
$visual_form_structure = array(); |
| 268 |
|
| 269 |
// calendar |
| 270 |
$visual_form_structure[] = array( |
| 271 |
'type' => 'calendar', |
| 272 |
'name' => 'calendar', |
| 273 |
'obligatory' => 'On', |
| 274 |
'if_exist_required' => 'On', |
| 275 |
'label' => '' //__('Select date', 'booking') |
| 276 |
); |
| 277 |
// First Name |
| 278 |
$visual_form_structure[] = array( |
| 279 |
'type' => 'text', |
| 280 |
'name' => 'name', |
| 281 |
'obligatory' => 'Off', |
| 282 |
'active' => empty( get_bk_option( 'booking_form_field_active1' ) ) ? 'On' : get_bk_option( 'booking_form_field_active1' ), |
| 283 |
'required' => empty( get_bk_option( 'booking_form_field_required1' ) ) ? 'On' : get_bk_option( 'booking_form_field_required1' ), |
| 284 |
'label' => empty( get_bk_option( 'booking_form_field_label1' ) ) ? __( 'First Name', 'booking' ) : get_bk_option( 'booking_form_field_label1' ) |
| 285 |
); |
| 286 |
// Second Name |
| 287 |
$visual_form_structure[] = array( |
| 288 |
'type' => 'text', |
| 289 |
'name' => 'secondname', |
| 290 |
'obligatory' => 'Off', |
| 291 |
'active' => empty( get_bk_option( 'booking_form_field_active2' ) ) ? 'On' : get_bk_option( 'booking_form_field_active2' ), |
| 292 |
'required' => empty( get_bk_option( 'booking_form_field_required2' ) ) ? 'On' : get_bk_option( 'booking_form_field_required2' ), |
| 293 |
'label' => empty( get_bk_option( 'booking_form_field_label2' ) ) ? __( 'Second Name', 'booking' ) : get_bk_option( 'booking_form_field_label2' ) |
| 294 |
); |
| 295 |
// Email |
| 296 |
$visual_form_structure[] = array( |
| 297 |
'type' => 'email', |
| 298 |
'name' => 'email', |
| 299 |
'obligatory' => 'On', |
| 300 |
'active' => 'On', |
| 301 |
'required' => 'On', |
| 302 |
'label' => empty( get_bk_option( 'booking_form_field_label3' ) ) ? __( 'Email', 'booking' ) : get_bk_option( 'booking_form_field_label3' ) |
| 303 |
); |
| 304 |
// Visitors |
| 305 |
$visual_form_structure[] = array( |
| 306 |
'type' => 'selectbox', |
| 307 |
'name' => 'visitors', |
| 308 |
'obligatory' => 'Off', |
| 309 |
'active' => empty( get_bk_option( 'booking_form_field_active6' ) ) ? 'On' : get_bk_option( 'booking_form_field_active6' ), |
| 310 |
'required' => empty( get_bk_option( 'booking_form_field_required6' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required6' ), |
| 311 |
'label' => empty( get_bk_option( 'booking_form_field_label6' ) ) ? __( 'Visitors', 'booking' ) : get_bk_option( 'booking_form_field_label6' ), |
| 312 |
'value' => (empty( get_bk_option( 'booking_form_field_values6' ) ) |
| 313 |
? ( '1' . "\r\n" . '2' . "\r\n" . '3' . "\r\n" . '4' ) |
| 314 |
: get_bk_option( 'booking_form_field_values6' ) ) |
| 315 |
); |
| 316 |
// Phone |
| 317 |
$visual_form_structure[] = array( |
| 318 |
'type' => 'text', |
| 319 |
'name' => 'phone', |
| 320 |
'obligatory' => 'Off', |
| 321 |
'active' => empty( get_bk_option( 'booking_form_field_active4' ) ) ? 'On' : get_bk_option( 'booking_form_field_active4' ), |
| 322 |
'required' => empty( get_bk_option( 'booking_form_field_required4' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required4' ), |
| 323 |
'label' => empty( get_bk_option( 'booking_form_field_label4' ) ) ? __( 'Phone', 'booking' ) : get_bk_option( 'booking_form_field_label4' ) |
| 324 |
); |
| 325 |
// Details - textarea |
| 326 |
$visual_form_structure[] = array( |
| 327 |
'type' => 'textarea', |
| 328 |
'name' => 'details', |
| 329 |
'obligatory' => 'Off', |
| 330 |
'active' => empty( get_bk_option( 'booking_form_field_active5' ) ) ? 'On' : get_bk_option( 'booking_form_field_active5' ), |
| 331 |
'required' => empty( get_bk_option( 'booking_form_field_required5' ) ) ? 'Off' : get_bk_option( 'booking_form_field_required5' ), |
| 332 |
'label' => empty( get_bk_option( 'booking_form_field_label5' ) ) ? __( 'Details', 'booking' ) : get_bk_option( 'booking_form_field_label5' ) |
| 333 |
); |
| 334 |
// CAPTCHA |
| 335 |
$visual_form_structure[] = array( |
| 336 |
'type' => 'captcha', |
| 337 |
'name' => 'captcha', |
| 338 |
'obligatory' => 'Off', |
| 339 |
'active' => ( get_bk_option( 'booking_is_use_captcha' ) == 'On' ) ? 'On' : 'Off', |
| 340 |
'required' => 'On', |
| 341 |
'if_exist_required' => 'On', |
| 342 |
'label' => '' |
| 343 |
); |
| 344 |
// Submit |
| 345 |
$visual_form_structure[] = array( |
| 346 |
'type' => 'submit', |
| 347 |
'name' => 'submit', |
| 348 |
'obligatory' => 'On', |
| 349 |
'active' => 'On', |
| 350 |
'required' => 'On', |
| 351 |
'if_exist_required' => 'On', |
| 352 |
'label' => empty( get_bk_option( 'booking_send_button_title' ) ) ? __( 'Send', 'booking' ) : get_bk_option( 'booking_send_button_title' ) |
| 353 |
); |
| 354 |
return $visual_form_structure; |
| 355 |
} |
| 356 |
|
| 357 |
|