| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @description Action for Template Setup pages |
| 4 |
* @category Setup Action |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site http://oplugins.com/ |
| 8 |
* @email [email protected] |
| 9 |
* |
| 10 |
* @modified 2024-10-13 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
// ------------------------------------------------------------------------------------------------------------- |
| 17 |
// == Action - Form Structure == |
| 18 |
// ------------------------------------------------------------------------------------------------------------- |
| 19 |
/** |
| 20 |
* Template - Form Structure |
| 21 |
* |
| 22 |
* Help Tips: |
| 23 |
* |
| 24 |
* <script type="text/html" id="tmpl-template_name_a"> |
| 25 |
* Escaped: {{data.test_key}} |
| 26 |
* HTML: {{{data.test_key}}} |
| 27 |
* JS: <# if (true) { alert( 1 ); } #> |
| 28 |
* </script> |
| 29 |
* |
| 30 |
* var template__var = wp.template( 'template_name_a' ); |
| 31 |
* |
| 32 |
* jQuery( '.content' ).html( template__var( { 'test_key' => '<strong>Data</strong>' } ) ); |
| 33 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
|
| 37 |
function wpbc_template__form_structure__action_validate_data( $post_data ){ |
| 38 |
|
| 39 |
$escaped_data = array( |
| 40 |
'wpbc_swp_booking_form_template_pro' => '' |
| 41 |
); |
| 42 |
|
| 43 |
$key = 'wpbc_swp_booking_form_template_pro'; |
| 44 |
if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) { |
| 45 |
if ( is_array( $post_data[ $key ] ) ) { |
| 46 |
$post_data[ $key ] = $post_data[ $key ][0]; |
| 47 |
} |
| 48 |
$escaped_data[ $key ] = wpbc_clean_text_value( $post_data[ $key ] ); |
| 49 |
} |
| 50 |
return $escaped_data; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
/** |
| 56 |
* Update "General Data" like "Email" and "Title" |
| 57 |
* |
| 58 |
* @param $cleaned_data array( |
| 59 |
* 'wpbc_swp_business_name' => '', |
| 60 |
* 'wpbc_swp_booking_who_setup' => '', |
| 61 |
* 'wpbc_swp_industry' => '', |
| 62 |
* 'wpbc_swp_email' => '', |
| 63 |
* 'wpbc_swp_accept_send' => 'Off' |
| 64 |
* |
| 65 |
* ) |
| 66 |
* |
| 67 |
* @return void |
| 68 |
*/ |
| 69 |
function wpbc_setup__update__form_structure( $cleaned_data ){ |
| 70 |
|
| 71 |
/** |
| 72 |
if ( ! empty( $cleaned_data['wpbc_swp_booking_form_template'] ) ) { |
| 73 |
|
| 74 |
//update_bk_option( 'booking_range_start_day_dynamic' , '-1' ); |
| 75 |
|
| 76 |
// Structure |
| 77 |
$booking_form_structure = $cleaned_data['wpbc_swp_booking_form_template']; // vertical form_right form_center |
| 78 |
update_bk_option( 'booking_form_structure_type' , $booking_form_structure ); |
| 79 |
|
| 80 |
// Default Form |
| 81 |
//$visual_form_structure = wpbc_simple_form__visual__get_default_form__without_times(); |
| 82 |
//update_bk_option( 'booking_form_visual', $visual_form_structure ); |
| 83 |
|
| 84 |
$visual_form_structure = get_bk_option( 'booking_form_visual' ); |
| 85 |
update_bk_option( 'booking_form', wpbc_simple_form__get_booking_form__as_shortcodes( $visual_form_structure ) ); |
| 86 |
update_bk_option( 'booking_form_show', wpbc_simple_form__get_form_show__as_shortcodes( $visual_form_structure ) ); |
| 87 |
|
| 88 |
} |
| 89 |
*/ |
| 90 |
|
| 91 |
if ( ! empty( $cleaned_data['wpbc_swp_booking_form_template_pro'] ) ) { |
| 92 |
|
| 93 |
$booking_wizard_data = get_bk_option( 'booking_wizard_data' ); |
| 94 |
|
| 95 |
$wpbc_swp_booking_types = ''; |
| 96 |
if ( |
| 97 |
( ! empty( $booking_wizard_data ) ) && |
| 98 |
( ! empty( $booking_wizard_data['save_and_continue__bookings_types'] ) ) && |
| 99 |
( ! empty( $booking_wizard_data['save_and_continue__bookings_types']['wpbc_swp_booking_types'] ) ) |
| 100 |
) { |
| 101 |
$wpbc_swp_booking_types = $booking_wizard_data['save_and_continue__bookings_types']['wpbc_swp_booking_types']; |
| 102 |
} |
| 103 |
|
| 104 |
list( $is_pro, $cleaned_data['wpbc_swp_booking_form_template_pro'] ) = explode( '|', $cleaned_data['wpbc_swp_booking_form_template_pro'] ); |
| 105 |
|
| 106 |
if ( 'free' === $is_pro ) { |
| 107 |
|
| 108 |
$booking_form_structure = $cleaned_data['wpbc_swp_booking_form_template_pro']; // vertical form_right form_center. |
| 109 |
update_bk_option( 'booking_form_structure_type', $booking_form_structure ); |
| 110 |
|
| 111 |
|
| 112 |
$visual_form_structure = ( 'time_slots_appointments' === $wpbc_swp_booking_types ) |
| 113 |
? wpbc_simple_form__visual__get_default_form__times_30min() |
| 114 |
: wpbc_simple_form__visual__get_default_form__without_times(); |
| 115 |
|
| 116 |
switch ( $booking_form_structure ) { |
| 117 |
|
| 118 |
case 'wizard_services_a': |
| 119 |
$visual_form_structure = wpbc_simple_form__visual__get_default_form__service_duration_a(); |
| 120 |
update_bk_option( 'booking_form_layout_max_cols', 2 ); |
| 121 |
update_bk_option( 'booking_form_layout_width', '100' ); |
| 122 |
update_bk_option( 'booking_form_layout_width_px_pr', '%' ); |
| 123 |
break; |
| 124 |
|
| 125 |
case 'wizard_2columns': |
| 126 |
update_bk_option( 'booking_form_layout_max_cols', 2 ); |
| 127 |
update_bk_option( 'booking_form_layout_width', '100' ); |
| 128 |
update_bk_option( 'booking_form_layout_width_px_pr', '%' ); |
| 129 |
break; |
| 130 |
|
| 131 |
default: |
| 132 |
update_bk_option( 'booking_form_layout_max_cols', ( ( 'vertical' === $booking_form_structure ) ? 2 : 1 ) ); |
| 133 |
update_bk_option( 'booking_form_layout_width', ( ( 'vertical' === $booking_form_structure ) ? '740' : '440' ) ); |
| 134 |
update_bk_option( 'booking_form_layout_width_px_pr', 'px' ); |
| 135 |
} |
| 136 |
|
| 137 |
update_bk_option( 'booking_form_visual', $visual_form_structure ); |
| 138 |
update_bk_option( 'booking_form', wpbc_simple_form__get_booking_form__as_shortcodes( $visual_form_structure ) ); |
| 139 |
update_bk_option( 'booking_form_show', wpbc_simple_form__get_form_show__as_shortcodes( $visual_form_structure ) ); |
| 140 |
|
| 141 |
} else { |
| 142 |
|
| 143 |
update_bk_option( 'booking_form', str_replace( array( '\\n\\', '\\n', ), "\n", wpbc_get__predefined_booking_form__template( $cleaned_data['wpbc_swp_booking_form_template_pro'] ) ) ); |
| 144 |
update_bk_option( 'booking_form_show', str_replace( array( '\\n\\', '\\n', ), "\n", wpbc_get__predefined_booking_data__template( $cleaned_data['wpbc_swp_booking_form_template_pro'] ) ) ); |
| 145 |
|
| 146 |
} |
| 147 |
} |
| 148 |
} |