| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
class wpdev_booking { |
| 5 |
|
| 6 |
public $popover_front_end_js_is_writed; //FixIn: Flex TimeLine 1.0 -- previos this was private and not public property |
| 7 |
|
| 8 |
// <editor-fold defaultstate="collapsed" desc=" C O N S T R U C T O R & P r o p e r t i e s "> |
| 9 |
|
| 10 |
var $wpdev_bk_personal; |
| 11 |
|
| 12 |
function __construct() { |
| 13 |
|
| 14 |
// In AJAX request it DO NOT RUNNING. Important note |
| 15 |
|
| 16 |
$this->popover_front_end_js_is_writed = false; |
| 17 |
|
| 18 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 19 |
$this->wpdev_bk_personal = new wpdev_bk_personal(); |
| 20 |
} else { |
| 21 |
$this->wpdev_bk_personal = false; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
// User defined - hooks |
| 26 |
add_action( 'wpdev_bk_add_calendar', array( &$this, 'add_calendar_action' ), 10, 2 ); |
| 27 |
add_action( 'wpdev_bk_add_form', array( &$this, 'add_booking_form_action' ), 10, 2 ); |
| 28 |
add_bk_action( 'wpdevbk_add_form', array( &$this, 'add_booking_form_action' ) ); |
| 29 |
add_filter( 'wpdev_bk_get_form', array( &$this, 'get_booking_form_action' ), 10, 2 ); |
| 30 |
add_bk_filter( 'wpdevbk_get_booking_form', array( &$this, 'get_booking_form_action' ) ); |
| 31 |
add_filter( 'wpdev_bk_get_showing_date_format', array( &$this, 'get_showing_date_format' ), 10, 1 ); |
| 32 |
|
| 33 |
// Get script for calendar activation |
| 34 |
add_bk_filter( 'pre_get_calendar_html', array( &$this, 'pre_get_calendar_html' ) ); |
| 35 |
|
| 36 |
add_action( 'init', array( $this, 'wpbc_shortcodes_init' ), 9999 ); // <- priority to load it last |
| 37 |
} |
| 38 |
// </editor-fold> |
| 39 |
|
| 40 |
|
| 41 |
/** |
| 42 |
* S H O R T C O D E s Init |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
function wpbc_shortcodes_init(){ |
| 47 |
|
| 48 |
add_shortcode( 'booking', array( &$this, 'booking_shortcode' ) ); |
| 49 |
add_shortcode( 'bookingcalendar', array( &$this, 'booking_calendar_only_shortcode' ) ); |
| 50 |
add_shortcode( 'bookingform', array( &$this, 'bookingform_shortcode' ) ); |
| 51 |
add_shortcode( 'bookingedit', array( &$this, 'bookingedit_shortcode' ) ); |
| 52 |
add_shortcode( 'bookingsearch', array( &$this, 'bookingsearch_shortcode' ) ); |
| 53 |
add_shortcode( 'bookingsearchresults', array( &$this, 'bookingsearchresults_shortcode' ) ); |
| 54 |
add_shortcode( 'bookingselect', array( &$this, 'bookingselect_shortcode' ) ); |
| 55 |
add_shortcode( 'bookingresource', array( &$this, 'bookingresource_shortcode' ) ); |
| 56 |
add_shortcode( 'bookingtimeline', array( &$this, 'bookingtimeline_shortcode' ) ); |
| 57 |
add_shortcode( 'bookingcustomerlisting', array( &$this, 'bookingcustomerlisting_shortcode' ) ); // FixIn: 8.1.3.5. |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
// <editor-fold defaultstate="collapsed" desc=" S U P P O R T F U N C T I O N S "> |
| 63 |
|
| 64 |
function silent_deactivate_WPBC() { |
| 65 |
deactivate_plugins( WPBC_PLUGIN_DIRNAME . '/' . WPBC_PLUGIN_FILENAME, true ); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
// Change date format |
| 70 |
function get_showing_date_format( $mydate ) { |
| 71 |
$date_format = get_bk_option( 'booking_date_format' ); |
| 72 |
if ( $date_format == '' ) { |
| 73 |
$date_format = "d.m.Y"; |
| 74 |
} |
| 75 |
|
| 76 |
$time_format = get_bk_option( 'booking_time_format' ); |
| 77 |
if ( $time_format !== false ) { |
| 78 |
$time_format = ' ' . $time_format; |
| 79 |
$my_time = gmdate( 'H:i:s', $mydate ); |
| 80 |
if ( $my_time == '00:00:00' ) { |
| 81 |
$time_format = ''; |
| 82 |
} |
| 83 |
} else { |
| 84 |
$time_format = ''; |
| 85 |
} |
| 86 |
|
| 87 |
// return gmdate($date_format . $time_format , $mydate); |
| 88 |
return date_i18n( $date_format, $mydate ) . '<sup class="booking-table-time">' . date_i18n( $time_format, $mydate ) . '</sup>'; |
| 89 |
} |
| 90 |
|
| 91 |
// </editor-fold> |
| 92 |
|
| 93 |
|
| 94 |
// <editor-fold defaultstate="collapsed" desc=" B O O K I N G s A D M I N F U N C T I O N s "> |
| 95 |
|
| 96 |
/** |
| 97 |
* Generate booking CAPTCHA fields for booking form |
| 98 |
* |
| 99 |
* @param $bk_tp resource ID |
| 100 |
* |
| 101 |
* @return string|true |
| 102 |
*/ |
| 103 |
function createCapthaContent($bk_tp) { |
| 104 |
|
| 105 |
$admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url( 'admin.php?' ) ), '/' ); |
| 106 |
|
| 107 |
$server_request_uri = ( ( isset( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */ |
| 108 |
|
| 109 |
if ( ( get_bk_option( 'booking_is_use_captcha' ) !== 'On' ) |
| 110 |
|| ( |
| 111 |
( strpos( $server_request_uri, $admin_uri ) !== false ) |
| 112 |
&& ( ! wpbc_is_settings_form_page() ) |
| 113 |
) |
| 114 |
) { |
| 115 |
return ''; |
| 116 |
} else { |
| 117 |
|
| 118 |
$html = wpbc_captcha__simple__generate_html_content( $bk_tp ); |
| 119 |
|
| 120 |
return $html; |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
// Get default Booking resource |
| 125 |
function get_default_type() { |
| 126 |
|
| 127 |
if ( $this->wpdev_bk_personal !== false ) { |
| 128 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 129 |
if ( ( isset( $_GET['booking_type'] ) ) && ( $_GET['booking_type'] != '' ) ) { |
| 130 |
$bk_type = sanitize_text_field( wp_unslash( $_GET['booking_type'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 131 |
} else { |
| 132 |
$bk_type = $this->wpdev_bk_personal->get_default_booking_resource_id(); |
| 133 |
} |
| 134 |
} else { |
| 135 |
$bk_type = 1; |
| 136 |
} |
| 137 |
|
| 138 |
return $bk_type; |
| 139 |
} |
| 140 |
|
| 141 |
// </editor-fold> |
| 142 |
|
| 143 |
|
| 144 |
// <editor-fold defaultstate="collapsed" desc=" C L I E N T S I D E & H O O K S "> |
| 145 |
|
| 146 |
|
| 147 |
// Get HTML for the initilizing inline calendars |
| 148 |
function pre_get_calendar_html( $resource_id=1, $cal_count=1, $bk_otions=array() ){ |
| 149 |
//SHORTCODE: |
| 150 |
/* |
| 151 |
* [booking type=56 form_type='standard' nummonths=4 |
| 152 |
* options='{calendar months_num_in_row=2 width=682px cell_height=48px}'] |
| 153 |
*/ |
| 154 |
|
| 155 |
$bk_otions = wpbc_parse_calendar_options($bk_otions); |
| 156 |
/* options: |
| 157 |
[months_num_in_row] => 2 |
| 158 |
[width] => 341px define: width: 100%; max-width:341px; |
| 159 |
[strong_width] => 341px define: width:341px; |
| 160 |
[cell_height] => 48px |
| 161 |
*/ |
| 162 |
$width = $months_num_in_row = $cell_height = ''; |
| 163 |
|
| 164 |
if (!empty($bk_otions)){ |
| 165 |
|
| 166 |
if ( isset( $bk_otions['months_num_in_row'] ) ) { |
| 167 |
$months_num_in_row = $bk_otions['months_num_in_row']; |
| 168 |
} |
| 169 |
|
| 170 |
if ( isset( $bk_otions['width'] ) ) { |
| 171 |
$width = 'width:100%;max-width:' . $bk_otions['width'] . ';'; // FixIn: 9.3.1.5. |
| 172 |
} |
| 173 |
if ( isset( $bk_otions['strong_width'] ) ) { |
| 174 |
$width .= 'width:' . $bk_otions['strong_width'] . ';'; // FixIn: 9.3.1.6. |
| 175 |
} |
| 176 |
|
| 177 |
if ( isset( $bk_otions['cell_height'] ) ) { |
| 178 |
$cell_height = $bk_otions['cell_height']; |
| 179 |
} |
| 180 |
if ( isset( $bk_otions['strong_cell_height'] ) ) { // FixIn: 9.7.3.3. |
| 181 |
$cell_height = $bk_otions['strong_cell_height'] . '!important;'; |
| 182 |
} |
| 183 |
} |
| 184 |
/* FixIn: 9.7.3.4 */ |
| 185 |
|
| 186 |
if ( ! empty( $cell_height ) ) { |
| 187 |
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet |
| 188 |
$style = '<style type="text/css" rel="stylesheet" >' . '.hasDatepick .datepick-inline .datepick-title-row th,' . '.hasDatepick .datepick-inline .datepick-days-cell{' . ' height: ' . $cell_height . '; ' . '}' . '</style>'; |
| 189 |
} else { |
| 190 |
$style = ''; |
| 191 |
} |
| 192 |
|
| 193 |
// FixIn: 8.2.1.27. |
| 194 |
$booking_timeslot_day_bg_as_available = get_bk_option( 'booking_timeslot_day_bg_as_available' ); |
| 195 |
|
| 196 |
$booking_timeslot_day_bg_as_available = ( $booking_timeslot_day_bg_as_available === 'On' ) ? ' wpbc_timeslot_day_bg_as_available' : ''; |
| 197 |
|
| 198 |
//FixIn: 9.8.1 |
| 199 |
$is_custom_width_css = ( empty( $width ) ) ? ' wpbc_no_custom_width ' : ''; |
| 200 |
|
| 201 |
$calendar = $style. |
| 202 |
'<div class="wpbc_cal_container bk_calendar_frame' . $is_custom_width_css . ' months_num_in_row_' . $months_num_in_row . ' cal_month_num_' . $cal_count . $booking_timeslot_day_bg_as_available . '" style="' . $width . '">' . |
| 203 |
'<div id="calendar_booking' . $resource_id . '">' . |
| 204 |
__('Calendar is loading...' ,'booking'). |
| 205 |
'</div>'. |
| 206 |
'</div>'. |
| 207 |
''; |
| 208 |
|
| 209 |
$booking_is_show_powered_by_notice = get_bk_option( 'booking_is_show_powered_by_notice' ); |
| 210 |
if ( ( ! class_exists( 'wpdev_bk_personal' ) ) && ( $booking_is_show_powered_by_notice == 'On' ) ) { |
| 211 |
$calendar .= '<div style="font-size:7px;text-align:left;margin:0 0 10px;text-shadow: none;">Powered by <a href="https://wpbookingcalendar.com" style="font-size:7px;" target="_blank" title="Booking Calendar plugin for WordPress">Booking Calendar</a></div>'; |
| 212 |
} |
| 213 |
|
| 214 |
$calendar .= '<textarea id="date_booking' . $resource_id . '" name="date_booking' . $resource_id . '" autocomplete="off" style="display:none;"></textarea>'; // Calendar code |
| 215 |
|
| 216 |
$calendar .= wpbc_get_calendar_legend(); // FixIn: 9.4.3.6. |
| 217 |
|
| 218 |
$calendar_css_class_outer = 'wpbc_calendar_wraper'; |
| 219 |
|
| 220 |
// FixIn: 7.0.1.24. |
| 221 |
$is_booking_change_over_days_triangles = get_bk_option( 'booking_change_over_days_triangles' ); |
| 222 |
if ( $is_booking_change_over_days_triangles !== 'Off' ) { |
| 223 |
$calendar_css_class_outer .= ' wpbc_change_over_triangle'; |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
// filenames, such as 'multidays.css' |
| 228 |
$calendar_skin_name = basename( get_bk_option( 'booking_skin' ) ); |
| 229 |
if ( wpbc_is_calendar_skin_legacy( $calendar_skin_name ) ) { |
| 230 |
$calendar_css_class_outer .= ' wpbc_calendar_skin_legacy'; //. wpbc_get_slug_format( get_bk_option( 'booking_skin' ) ); |
| 231 |
} |
| 232 |
|
| 233 |
$calendar = '<div class="' . esc_attr( $calendar_css_class_outer ) . '">' . $calendar . '</div>'; |
| 234 |
|
| 235 |
return $calendar; |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
// Get booking form |
| 241 |
function get_booking_form_action( $resource_id = 1, $my_boook_count = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $start_month_calendar = false, $bk_otions = array() ) { |
| 242 |
|
| 243 |
$res = $this->add_booking_form_action($resource_id,$my_boook_count, 0, $my_booking_form , $my_selected_dates_without_calendar, $start_month_calendar, $bk_otions ); |
| 244 |
return $res; |
| 245 |
} |
| 246 |
|
| 247 |
//Show booking form from action call - wpdev_bk_add_form |
| 248 |
function add_booking_form_action( $resource_id = 1, $cal_count = 1, $is_echo = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $start_month_calendar = false, $bk_otions = array() ) { |
| 249 |
|
| 250 |
$additional_bk_types = array(); |
| 251 |
if ( strpos($resource_id,';') !== false ) { |
| 252 |
$additional_bk_types = explode(';',$resource_id); |
| 253 |
$resource_id = $additional_bk_types[0]; |
| 254 |
} |
| 255 |
|
| 256 |
//-------------------------------------------------------------------------------------------------------------- |
| 257 |
// Check if booking resource exist |
| 258 |
if ( $resource_id == '' ) { |
| 259 |
$my_result = __( 'Booking resource type is not defined. This can be, when at the URL is wrong booking hash.', 'booking' ); |
| 260 |
if ( $is_echo ) { |
| 261 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 262 |
echo $my_result; |
| 263 |
} else { |
| 264 |
return $my_result; |
| 265 |
} |
| 266 |
|
| 267 |
return; |
| 268 |
} |
| 269 |
|
| 270 |
$is_booking_resource_exist = apply_bk_filter('wpdev_is_booking_resource_exist',true, $resource_id, $is_echo ); |
| 271 |
if (! $is_booking_resource_exist) { |
| 272 |
if ( $is_echo ) echo 'Booking resource does not exist.' . ' [ID=' . esc_attr( $resource_id ) . ']'; |
| 273 |
return 'Booking resource does not exist.' . ' [ID=' . esc_attr( $resource_id ) . ']'; |
| 274 |
} |
| 275 |
|
| 276 |
//-------------------------------------------------------------------------------------------------------------- |
| 277 |
// Define $this->client_side_active_params_of_user to specific User, |
| 278 |
// depends from belonging booking resource to specific User |
| 279 |
make_bk_action('check_multiuser_params_for_client_side', $resource_id ); |
| 280 |
|
| 281 |
//-------------------------------------------------------------------------------------------------------------- |
| 282 |
// Get Booking ID and booking resource ID, if we EDIT booking |
| 283 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 284 |
if ( isset( $_GET['booking_hash'] ) ) { |
| 285 |
|
| 286 |
$get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 287 |
|
| 288 |
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash ); |
| 289 |
|
| 290 |
$is_error = false; // FixIn: 9.1.3.2. |
| 291 |
if ( $my_booking_id_type !== false ) { |
| 292 |
|
| 293 |
list( $my_edited_bk_id, $my_boook_type ) = $my_booking_id_type; |
| 294 |
|
| 295 |
if ( $my_boook_type == '' ) { |
| 296 |
$is_error ='<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); |
| 297 |
} |
| 298 |
} else { |
| 299 |
$is_error = '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); |
| 300 |
} |
| 301 |
|
| 302 |
if ( false !== $is_error ) { |
| 303 |
if ( $is_echo ) { |
| 304 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 305 |
echo $is_error; |
| 306 |
} |
| 307 |
return $is_error; |
| 308 |
} |
| 309 |
|
| 310 |
// Check situation when we have editing "child booking resource", so need to reupdate calendar and form to have it for parent resource. |
| 311 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 312 |
if ( ( ! isset( $_GET['booking_pay'] ) ) // FixIn: 10.10.1.2 && ( ! isset( $_GET['resource_no_update'] ) ) |
| 313 |
&& ( function_exists( 'wpbc_is_this_child_resource' ) ) |
| 314 |
&& ( wpbc_is_this_child_resource( $my_boook_type ) ) |
| 315 |
){ |
| 316 |
$bk_parent_br_id = wpbc_get_parent_resource( $my_boook_type ); |
| 317 |
$resource_id = $bk_parent_br_id; |
| 318 |
} |
| 319 |
} |
| 320 |
|
| 321 |
//-------------------------------------------------------------------------------------------------------------- |
| 322 |
// Get JS vars for Booked dates | Rates | Availability & define function for showing calendar |
| 323 |
|
| 324 |
$start_script_code = wpbc__calendar__load( array( |
| 325 |
'resource_id' => $resource_id, |
| 326 |
'aggregate_resource_id_arr' => $additional_bk_types, |
| 327 |
'selected_dates_without_calendar' => $my_selected_dates_without_calendar, |
| 328 |
'calendar_number_of_months' => $cal_count, |
| 329 |
'start_month_calendar' => $start_month_calendar, |
| 330 |
'shortcode_options' => $bk_otions, |
| 331 |
'custom_form' => ( isset( $_GET['booking_form'] ) ) ? wpbc_clean_text_value( $_GET['booking_form'] ) : $my_booking_form // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 332 |
)); |
| 333 |
|
| 334 |
|
| 335 |
if ( $my_selected_dates_without_calendar !== '' ) { // FixIn: 9.3.1.1. |
| 336 |
// Disable booked time slots, for predefined selected date in the booking form (it's shortcode for booking form, without the calendar) |
| 337 |
$start_script_code .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7. |
| 338 |
$start_script_code .= " bkDisableBookedTimeSlots( jQuery( '#date_booking{$resource_id}' ).val(), {$resource_id} ); "; |
| 339 |
$start_script_code .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7. |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
//-------------------------------------------------------------------------------------------------------------- |
| 344 |
// Get booking form content |
| 345 |
$my_result = ' ' . $this->get__client_side_booking_content($resource_id, $my_booking_form, $my_selected_dates_without_calendar, $cal_count, $bk_otions ) . ' ' . $start_script_code ; |
| 346 |
|
| 347 |
|
| 348 |
$my_result = apply_filters('wpdev_booking_form', $my_result , $resource_id); // Add DIV structure, where to show payment form |
| 349 |
|
| 350 |
|
| 351 |
make_bk_action('finish_check_multiuser_params_for_client_side', $resource_id ); |
| 352 |
|
| 353 |
if ( $is_echo ) { |
| 354 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 355 |
echo $my_result; |
| 356 |
} else { |
| 357 |
return $my_result; |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
/** |
| 363 |
* For [bookingcalendar ... ] shortcode Only! |
| 364 |
* |
| 365 |
* @param $resource_id |
| 366 |
* @param $cal_count |
| 367 |
* @param $is_echo |
| 368 |
* @param $start_month_calendar |
| 369 |
* @param $bk_otions |
| 370 |
* |
| 371 |
* @return string|void |
| 372 |
*/ |
| 373 |
function add_calendar_action( $resource_id = 1, $cal_count = 1, $is_echo = 1, $start_month_calendar = false, $bk_otions = array() ) { |
| 374 |
|
| 375 |
$additional_bk_types = array(); |
| 376 |
if ( strpos($resource_id,';') !== false ) { |
| 377 |
$additional_bk_types = explode(';',$resource_id); |
| 378 |
$resource_id = $additional_bk_types[0]; |
| 379 |
} |
| 380 |
|
| 381 |
make_bk_action('check_multiuser_params_for_client_side', $resource_id ); |
| 382 |
|
| 383 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 384 |
if (isset($_GET['booking_hash'])) { |
| 385 |
$get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 386 |
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash ); |
| 387 |
if ($my_booking_id_type != false) |
| 388 |
if ($my_booking_id_type[1]=='') { |
| 389 |
$my_result = '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); |
| 390 |
if ( $is_echo ) { |
| 391 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 392 |
echo $my_result; |
| 393 |
} else { |
| 394 |
return $my_result; |
| 395 |
} |
| 396 |
return; |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
$start_script_code = wpbc__calendar__load( array( |
| 401 |
'resource_id' => $resource_id, |
| 402 |
'aggregate_resource_id_arr' => $additional_bk_types, |
| 403 |
'selected_dates_without_calendar' => '', |
| 404 |
'calendar_number_of_months' => $cal_count, |
| 405 |
'start_month_calendar' => $start_month_calendar, |
| 406 |
'custom_form' => 'standard' // Because we show only 'AVAILABILITY CALENDAR' without the form, at all. |
| 407 |
)); |
| 408 |
|
| 409 |
$my_result = '<div style="clear:both;height:10px;"></div>' . $this->pre_get_calendar_html( $resource_id, $cal_count, $bk_otions ); |
| 410 |
|
| 411 |
$my_result .= ' ' . $start_script_code ; |
| 412 |
|
| 413 |
$my_result = apply_filters('wpdev_booking_calendar', $my_result , $resource_id); |
| 414 |
|
| 415 |
|
| 416 |
$booking_form_is_using_bs_css = get_bk_option( 'booking_form_is_using_bs_css' ); |
| 417 |
$my_result = '<span ' . (($booking_form_is_using_bs_css == 'On') ? 'class="wpdevelop"' : '') . '>' . $my_result . '</span>'; |
| 418 |
|
| 419 |
make_bk_action('finish_check_multiuser_params_for_client_side', $resource_id ); |
| 420 |
|
| 421 |
if ( $is_echo ) { |
| 422 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 423 |
echo $my_result; |
| 424 |
} else { |
| 425 |
return $my_result; |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
// Get content at client side of C A L E N D A R |
| 430 |
function get__client_side_booking_content( $resource_id = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $cal_count = 1, $bk_otions = array() ) { |
| 431 |
|
| 432 |
$nl = '<div style="clear:both;height:10px;"></div>'; // New line |
| 433 |
if ($my_selected_dates_without_calendar=='') { |
| 434 |
// Get HTML with [calendar] shortcode and Styles for calendar. Get legend html. |
| 435 |
$calendar = $this->pre_get_calendar_html( $resource_id, $cal_count, $bk_otions ); |
| 436 |
} else { |
| 437 |
$calendar = '<textarea rows="3" cols="50" id="date_booking' . $resource_id . '" name="date_booking' . $resource_id . '" autocomplete="off" style="display:none;">' . $my_selected_dates_without_calendar . '</textarea>'; // Calendar code |
| 438 |
} |
| 439 |
|
| 440 |
// FixIn: 8.2.1.1. |
| 441 |
$form = '<a name="bklnk' . $resource_id . '" id="bklnk' . $resource_id . '"></a><div id="booking_form_div' . $resource_id . '" class="booking_form_div">'; |
| 442 |
// FixIn: 6.0.1.5. |
| 443 |
$custom_params = array(); |
| 444 |
if (! empty($bk_otions)) { |
| 445 |
$param ='\s*([name|value]+)=[\'"]{1}([^\'"]+)[\'"]{1}\s*'; // Find all possible options |
| 446 |
$pattern_to_search='%\s*{([^\s]+)' . $param . $param .'}\s*[,]?\s*%'; |
| 447 |
preg_match_all($pattern_to_search, $bk_otions, $matches, PREG_SET_ORDER); |
| 448 |
//debuge($matches); |
| 449 |
foreach ( $matches as $matche_value ) { |
| 450 |
if ( $matche_value[1] == 'parameter' ) { |
| 451 |
$custom_params[ $matche_value[3] ]= $matche_value[5]; |
| 452 |
} |
| 453 |
} |
| 454 |
} |
| 455 |
// FixIn: 6.0.1.5. |
| 456 |
|
| 457 |
if ( $this->wpdev_bk_personal !== false ) { |
| 458 |
$form .= $this->wpdev_bk_personal->get_booking_form( $resource_id, $my_booking_form, $custom_params ); |
| 459 |
} else { |
| 460 |
$form .= wpbc_simple_form__get_booking_form__as_html( $resource_id ); |
| 461 |
|
| 462 |
// Re-update other hints, such as availability times hint. |
| 463 |
$form = apply_filters( 'wpbc_booking_form_content__after_load', $form, $resource_id, $my_booking_form ); |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
// Insert calendar into form |
| 468 |
if ( strpos( $form, '[calendar]' ) !== false ) { |
| 469 |
$form = str_replace( '[calendar]', $calendar, $form ); |
| 470 |
} else { |
| 471 |
$form = '<div class="booking_form_div">' . $calendar . '</div>' . $nl . $form; |
| 472 |
} |
| 473 |
|
| 474 |
// Replace additional calendars like [calendar id=9] to HTML and JS code |
| 475 |
$form = apply_bk_filter( 'wpdev_check_for_additional_calendars_in_form' |
| 476 |
, $form |
| 477 |
, $resource_id |
| 478 |
, array( |
| 479 |
'booking_form' => $my_booking_form , |
| 480 |
'selected_dates' => $my_selected_dates_without_calendar , |
| 481 |
'cal_count' => $cal_count , |
| 482 |
'otions' => $bk_otions |
| 483 |
) |
| 484 |
); |
| 485 |
|
| 486 |
if ( strpos($form, '[captcha]') !== false ) { |
| 487 |
$captcha = $this->createCapthaContent($resource_id); |
| 488 |
$form =str_replace('[captcha]', $captcha ,$form); |
| 489 |
} |
| 490 |
|
| 491 |
// Set additional "Check in/out" times, if activated to use change-over days! |
| 492 |
$form = apply_filters( 'wpbc_booking_form_html__update__append_change_over_times', $form, $resource_id ); |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
// Add booking type field |
| 497 |
$form .= '<input id="bk_type' . $resource_id . '" name="bk_type' . $resource_id . '" class="" type="hidden" value="' . $resource_id . '" /></div>'; |
| 498 |
$submitting = '<div id="submiting' . $resource_id . '"></div><div class="form_bk_messages" id="form_bk_messages' . $resource_id . '" ></div>'; |
| 499 |
|
| 500 |
//Params: $action = -1, $name = "_wpnonce", $referer = true , $echo = true |
| 501 |
|
| 502 |
$wpbc_nonce = wp_nonce_field('CALCULATE_THE_COST', ( "wpbc_nonceCALCULATE_THE_COST" . $resource_id) , true , false ); |
| 503 |
|
| 504 |
|
| 505 |
$res = $form . $submitting . $wpbc_nonce; |
| 506 |
|
| 507 |
$my_random_id = time() * wp_rand(0,1000); |
| 508 |
$my_random_id = 'form_id'. $my_random_id; |
| 509 |
|
| 510 |
$booking_form_is_using_bs_css = get_bk_option( 'booking_form_is_using_bs_css'); |
| 511 |
$booking_form_format_type = get_bk_option( 'booking_form_format_type'); |
| 512 |
$booking_form_theme = get_bk_option( 'booking_form_theme'); |
| 513 |
|
| 514 |
$return_form = '<div id="' . $my_random_id . '" ' |
| 515 |
. ' class="wpbc_container wpbc_form wpbc_container_booking_form ' |
| 516 |
. ( ( wpbc_is_this_demo() == 'On' ) ? 'wpbc_demo_site ' : '' ) |
| 517 |
. esc_attr( $booking_form_theme ) . ' ' |
| 518 |
. ( ( $booking_form_is_using_bs_css == 'On' ) ? 'wpdevelop ' : '' ) |
| 519 |
. '" >' . |
| 520 |
'<form id="booking_form' . $resource_id . '" class="booking_form ' . $booking_form_format_type . '" method="post" action="">' . |
| 521 |
'<div id="ajax_respond_insert' . $resource_id . '" class="ajax_respond_insert" style="display:none;"></div>' . |
| 522 |
$res. |
| 523 |
'</form></div>'; |
| 524 |
|
| 525 |
$return_form .= '<div id="booking_form_garbage' . $resource_id . '" class="booking_form_garbage"></div>'; |
| 526 |
|
| 527 |
if ($my_selected_dates_without_calendar == '' ) { |
| 528 |
// Check according already shown Booking Calendar and set do not visible of it |
| 529 |
|
| 530 |
$return_form .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7. |
| 531 |
$return_form .= ' jQuery(".widget_wpdev_booking .booking_form.form-horizontal").removeClass("form-horizontal"); |
| 532 |
var visible_calendars_count = _wpbc.get_other_param( "calendars__on_this_page" ).length; |
| 533 |
if (visible_calendars_count !== null ) { |
| 534 |
for (var i=0;i< visible_calendars_count ;i++){ |
| 535 |
if ( _wpbc.get_other_param( "calendars__on_this_page" )[i] === ' . $resource_id . ' ) { |
| 536 |
document.getElementById("'.$my_random_id.'").innerHTML = "<span style=\'color:#A00;font-size:10px;\'>'. |
| 537 |
/* translators: 1: ... */ |
| 538 |
esc_js( sprintf( __( '%1$sWarning! Booking calendar for this booking resource are already at the page, please check more about this issue at %2$sthis page%3$s', 'booking' ) |
| 539 |
, '' |
| 540 |
, '' |
| 541 |
, ': https://wpbookingcalendar.com/faq/why-the-booking-calendar-widget-not-show-on-page/' |
| 542 |
) ) |
| 543 |
.'</span>"; |
| 544 |
jQuery("#'.$my_random_id.'").animate( {opacity: 1}, 10000 ).fadeOut(5000); |
| 545 |
return; |
| 546 |
} |
| 547 |
} |
| 548 |
_wpbc.get_other_param( "calendars__on_this_page" )[ visible_calendars_count ]=' . intval( $resource_id ) . '; |
| 549 |
} '; |
| 550 |
$return_form .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7. |
| 551 |
} else { |
| 552 |
//FixIn:6.1.1.16 // FixIn: 8.2.1.13. |
| 553 |
$return_form .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7. |
| 554 |
$return_form .= ' if(typeof( showCostHintInsideBkForm ) == "function") { showCostHintInsideBkForm(' . $resource_id . '); } '; |
| 555 |
$return_form .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7. |
| 556 |
} |
| 557 |
|
| 558 |
$is_use_auto_fill_for_logged = get_bk_option( 'booking_is_use_autofill_4_logged_user' ) ; |
| 559 |
|
| 560 |
|
| 561 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 562 |
if (! isset($_GET['booking_hash'])) |
| 563 |
if ($is_use_auto_fill_for_logged == 'On') { |
| 564 |
|
| 565 |
$curr_user = wpbc_get_current_user(); |
| 566 |
if ( $curr_user->ID > 0 ) { |
| 567 |
$user_nick_name = get_user_meta( $curr_user->ID, 'nickname' ); |
| 568 |
$user_nick_name = ( empty( $user_nick_name ) ) ? '' : $user_nick_name[0]; // FixIn: 8.7.1.5. |
| 569 |
|
| 570 |
$return_form .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7. |
| 571 |
$return_form .= 'var bk_af_submit_form = document.getElementById( "booking_form' . $resource_id . '" ); |
| 572 |
var bk_af_count = bk_af_submit_form.elements.length; |
| 573 |
var bk_af_element; |
| 574 |
var bk_af_reg; |
| 575 |
for (var bk_af_i=0; bk_af_i<bk_af_count; bk_af_i++) { |
| 576 |
bk_af_element = bk_af_submit_form.elements[bk_af_i]; |
| 577 |
// FixIn: 9.4.3.4. |
| 578 |
if ( ( bk_af_element.type == "text" ) || ( bk_af_element.type == "email" ) ) |
| 579 |
if ( bk_af_element.name !== ("date_booking' . $resource_id . '" ) ) |
| 580 |
{ |
| 581 |
// NickName // FixIn: 8.6.1.2. |
| 582 |
bk_af_reg = /^([A-Za-z0-9_\-\.])*(nickname){1}([A-Za-z0-9_\-\.])*$/; |
| 583 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 584 |
if (bk_af_element.value == "" ) |
| 585 |
bk_af_element.value = "' . str_replace( "'", '', $user_nick_name ) . '"; |
| 586 |
// Second Name |
| 587 |
bk_af_reg = /^([A-Za-z0-9_\-\.])*(last|second){1}([_\-\.])?name([A-Za-z0-9_\-\.])*$/; |
| 588 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 589 |
if (bk_af_element.value == "" ) |
| 590 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->last_name).'"; |
| 591 |
// First Name |
| 592 |
bk_af_reg = /^name([0-9_\-\.])*$/; |
| 593 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 594 |
if (bk_af_element.value == "" ) |
| 595 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->first_name).'"; |
| 596 |
bk_af_reg = /^([A-Za-z0-9_\-\.])*(first|my){1}([_\-\.])?name([A-Za-z0-9_\-\.])*$/; |
| 597 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 598 |
if (bk_af_element.value == "" ) |
| 599 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->first_name).'"; |
| 600 |
// Email |
| 601 |
bk_af_reg = /^(e)?([_\-\.])?mail([0-9_\-\.])*$/; |
| 602 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 603 |
if (bk_af_element.value == "" ) |
| 604 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->user_email).'"; |
| 605 |
// Phone |
| 606 |
bk_af_reg = /^([A-Za-z0-9_\-\.])*(phone|fone){1}([A-Za-z0-9_\-\.])*$/; |
| 607 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 608 |
if (bk_af_element.value == "" ) |
| 609 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->phone_number).'"; |
| 610 |
// NB Enfants |
| 611 |
bk_af_reg = /^(e)?([_\-\.])?nb_enfant([0-9_\-\.])*$/; |
| 612 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 613 |
if (bk_af_element.value == "" ) |
| 614 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->nb_enfant).'"; |
| 615 |
// URL |
| 616 |
bk_af_reg = /^([A-Za-z0-9_\-\.])*(URL|site|web|WEB){1}([A-Za-z0-9_\-\.])*$/; |
| 617 |
if(bk_af_reg.test(bk_af_element.name) != false) |
| 618 |
if (bk_af_element.value == "" ) |
| 619 |
bk_af_element.value = "'.str_replace("'",'',$curr_user->user_url).'"; |
| 620 |
} |
| 621 |
}'; |
| 622 |
$return_form .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7. |
| 623 |
} |
| 624 |
} |
| 625 |
|
| 626 |
return $return_form ; |
| 627 |
} |
| 628 |
// </editor-fold> |
| 629 |
|
| 630 |
|
| 631 |
// FixIn: 8.7.11.13. |
| 632 |
function wpbc_test_speed_shortcode( $attr ) { |
| 633 |
|
| 634 |
if ( wpbc_is_on_edit_page() ) { |
| 635 |
return wpbc_get_preview_for_shortcode( 'booking_test_speed', $attr ); // FixIn: 9.9.0.39. |
| 636 |
} |
| 637 |
|
| 638 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 639 |
|
| 640 |
echo '<h4>Booking Calendar Test</h4>'; |
| 641 |
|
| 642 |
$datesArray = Array( |
| 643 |
'2021-09-10' |
| 644 |
, '2021-09-11' |
| 645 |
, '2021-09-12' |
| 646 |
, '2021-09-13' |
| 647 |
, '2021-09-14' |
| 648 |
, '2021-09-15' |
| 649 |
, '2021-09-16' |
| 650 |
, '2021-09-17' |
| 651 |
, '2021-09-18' |
| 652 |
) ; |
| 653 |
for( $i = 0; $i < 1 ; $i++) { |
| 654 |
$result = wpbc_api_is_dates_booked( $datesArray, $resource_id = 13 ); |
| 655 |
//debuge((int) $result ); |
| 656 |
} |
| 657 |
|
| 658 |
debuge_speed('(int)'); |
| 659 |
echo '<hr/>'; |
| 660 |
echo '<hr/>'; |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
// <editor-fold defaultstate="collapsed" desc=" S H O R T C O D E S "> |
| 665 |
|
| 666 |
// FixIn: 8.1.3.5. |
| 667 |
/** Listing customners bookings in timeline view |
| 668 |
* |
| 669 |
* @param $attr - The same parameters as for bookingtimeline shortcode (function) |
| 670 |
* |
| 671 |
* @return mixed|string|void |
| 672 |
*/ |
| 673 |
function bookingcustomerlisting_shortcode( $attr ){ |
| 674 |
|
| 675 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 676 |
return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> '; |
| 677 |
} |
| 678 |
|
| 679 |
if ( wpbc_is_on_edit_page() ) { |
| 680 |
return wpbc_get_preview_for_shortcode( 'bookingcustomerlisting', $attr ); // FixIn: 9.9.0.39. |
| 681 |
} |
| 682 |
|
| 683 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 684 |
|
| 685 |
// FixIn: 8.4.5.11. |
| 686 |
if (! is_array($attr)) { |
| 687 |
$attr = array(); |
| 688 |
} |
| 689 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 690 |
if ( ( isset( $_GET['booking_hash'] ) ) || ( isset( $attr['booking_hash'] ) ) ) { |
| 691 |
|
| 692 |
|
| 693 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 694 |
if ( isset( $_GET['booking_hash'] ) ) { |
| 695 |
$get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 696 |
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash ); |
| 697 |
|
| 698 |
$attr['booking_hash'] = $get_booking_hash; |
| 699 |
} else { |
| 700 |
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $attr['booking_hash'] ); |
| 701 |
} |
| 702 |
|
| 703 |
if ( $my_booking_id_type !== false ) { |
| 704 |
|
| 705 |
if ( ! isset( $attr['type' ] ) ) { // 8.1.3.5.2 |
| 706 |
|
| 707 |
$br_list = wpbc_get_all_booking_resources_list(); |
| 708 |
$br_list = array_keys( $br_list ); |
| 709 |
$br_list = implode(',',$br_list); |
| 710 |
$attr['type' ] = $br_list; //wpbc_get_default_resource(); |
| 711 |
} |
| 712 |
if ( ! isset( $attr['view_days_num' ] ) ) { |
| 713 |
$attr['view_days_num' ] = 30; |
| 714 |
} |
| 715 |
if ( ! isset( $attr['scroll_start_date' ] ) ) { |
| 716 |
$attr['scroll_start_date' ] = ''; |
| 717 |
} |
| 718 |
if ( ! isset( $attr['scroll_day' ] ) ) { |
| 719 |
$attr['scroll_day' ] = 0; |
| 720 |
} |
| 721 |
if ( ! isset( $attr['scroll_month' ] ) ) { |
| 722 |
$attr['scroll_month' ] = 0; |
| 723 |
} |
| 724 |
if ( ! isset( $attr['header_title' ] ) ) { |
| 725 |
$attr['header_title' ] = __( 'My bookings' , 'booking'); |
| 726 |
} |
| 727 |
|
| 728 |
$timeline_results = $this->bookingtimeline_shortcode( $attr ); |
| 729 |
|
| 730 |
return $timeline_results ; |
| 731 |
|
| 732 |
} else { |
| 733 |
return '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . esc_html__('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); |
| 734 |
} |
| 735 |
|
| 736 |
} else { |
| 737 |
return __( 'This page can only be accessed through links in emails related to your booking.', 'booking' ) |
| 738 |
. ' <br/><em>' |
| 739 |
/* translators: 1: ... */ |
| 740 |
. sprintf( __( 'Please check more about configuration at %1$sthis page%2$s', 'booking' ), '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">', '</a>.' ) |
| 741 |
. '</em>'; |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
/** |
| 747 |
* TimeLine shortcode |
| 748 |
* |
| 749 |
* @param type $attr |
| 750 |
* @return type |
| 751 |
* |
| 752 |
* Shortcodes exmaples: |
| 753 |
* |
| 754 |
* |
| 755 |
** Matrix: |
| 756 |
* 1 Month View Mode: |
| 757 |
[bookingtimeline type="3,4,1,5,6,7,8,9,2,10,11,12,14" view_days_num=30 scroll_start_date="" scroll_month=0 header_title='All Bookings'] |
| 758 |
* 2 Months View Mode: |
| 759 |
[bookingtimeline type="1,5,6,7,8,9,2,10,11,12,3,4,14" view_days_num=60 scroll_start_date="" scroll_month=-1 header_title='All Bookings'] |
| 760 |
* 1 Week View Mode: |
| 761 |
[bookingtimeline type="3,4" view_days_num=7 scroll_start_date="" scroll_day=-7 header_title='All Bookings'] |
| 762 |
* 1 Day View Mode: |
| 763 |
[bookingtimeline type="3,4" view_days_num=1 scroll_start_date="" scroll_day=0 header_title='All Bookings'] |
| 764 |
|
| 765 |
** Single: |
| 766 |
* 1 Month View Mode: |
| 767 |
[bookingtimeline type="4" view_days_num=30 scroll_start_date="" scroll_day=-15 scroll_month=0 header_title='All Bookings'] |
| 768 |
* 3 Months View Mode: |
| 769 |
[bookingtimeline type="4" view_days_num=90 scroll_start_date="" scroll_day=-30] |
| 770 |
* 1 Year View Mode: |
| 771 |
[bookingtimeline type="4" view_days_num=365 scroll_start_date="" scroll_month=-3] |
| 772 |
|
| 773 |
|
| 774 |
*/ |
| 775 |
function bookingtimeline_shortcode($attr) { |
| 776 |
|
| 777 |
if ( wpbc_is_on_edit_page() ) { |
| 778 |
return wpbc_get_preview_for_shortcode( 'bookingtimeline', $attr ); // FixIn: 9.9.0.39. |
| 779 |
} |
| 780 |
|
| 781 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 782 |
|
| 783 |
// FixIn: 8.6.1.13. |
| 784 |
$timeline_results = bookingflextimeline_shortcode($attr); |
| 785 |
return $timeline_results; |
| 786 |
} |
| 787 |
|
| 788 |
// Replace MARK at post with content at client side ----- [booking nummonths='1' type='1'] |
| 789 |
function booking_shortcode($attr) { |
| 790 |
|
| 791 |
if ( wpbc_is_on_edit_page() ) { |
| 792 |
return wpbc_get_preview_for_shortcode( 'booking', $attr ); // FixIn: 9.9.0.39. |
| 793 |
} |
| 794 |
|
| 795 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 796 |
|
| 797 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 798 |
if ( isset( $_GET['booking_hash'] ) ) { |
| 799 |
return |
| 800 |
__( 'You need to use special shortcode [bookingedit] for booking editing.', 'booking' ) |
| 801 |
. ' ' |
| 802 |
/* translators: 1: ... */ |
| 803 |
. sprintf( __( 'Please check FAQ instruction how to configure it here %s', 'booking' ) |
| 804 |
, '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/">https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/</a>' |
| 805 |
); |
| 806 |
} |
| 807 |
|
| 808 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 809 |
|
| 810 |
$my_boook_count = get_bk_option( 'booking_client_cal_count' ); |
| 811 |
$my_boook_type = 1; |
| 812 |
$my_booking_form = 'standard'; |
| 813 |
$start_month_calendar = false; |
| 814 |
$bk_otions = array(); |
| 815 |
|
| 816 |
if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; } |
| 817 |
|
| 818 |
if ( isset( $attr['resource_id'] ) ) { |
| 819 |
$attr['type'] = intval( $attr['resource_id'] ); // FixIn: 10.2.2.2. |
| 820 |
} |
| 821 |
if ( isset( $attr['type'] ) ) { |
| 822 |
$my_boook_type = intval( $attr['type'] ); // FixIn: 10.2.2.2. |
| 823 |
} |
| 824 |
|
| 825 |
if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; } |
| 826 |
|
| 827 |
if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) { |
| 828 |
$additional_bk_types = $attr['agregate']; |
| 829 |
$my_boook_type .= ';'.$additional_bk_types; |
| 830 |
} |
| 831 |
if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) { |
| 832 |
$additional_bk_types = $attr['aggregate']; |
| 833 |
$my_boook_type .= ';'.$additional_bk_types; |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
if ( isset( $attr['startmonth'] ) ) { // Set start month of calendar, fomrat: '2011-1' |
| 838 |
|
| 839 |
$start_month_calendar = explode( '-', $attr['startmonth'] ); |
| 840 |
if ( (is_array($start_month_calendar)) && ( count($start_month_calendar) > 1) ) { } |
| 841 |
else $start_month_calendar = false; |
| 842 |
|
| 843 |
} |
| 844 |
|
| 845 |
if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; } |
| 846 |
|
| 847 |
$res = $this->add_booking_form_action( $my_boook_type, $my_boook_count, 0, $my_booking_form, '', $start_month_calendar, $bk_otions ); |
| 848 |
|
| 849 |
return $res; |
| 850 |
} |
| 851 |
|
| 852 |
// Replace MARK at post with content at client side ----- [booking nummonths='1' type='1'] |
| 853 |
function booking_calendar_only_shortcode($attr) { |
| 854 |
|
| 855 |
if ( wpbc_is_on_edit_page() ) { |
| 856 |
return wpbc_get_preview_for_shortcode( 'bookingcalendar', $attr ); // FixIn: 9.9.0.39. |
| 857 |
} |
| 858 |
|
| 859 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 860 |
|
| 861 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 862 |
|
| 863 |
$my_boook_count = get_bk_option( 'booking_client_cal_count' ); |
| 864 |
$my_boook_type = 1; |
| 865 |
$start_month_calendar = false; |
| 866 |
$bk_otions = array(); |
| 867 |
if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; } |
| 868 |
if ( isset( $attr['resource_id'] ) ) { |
| 869 |
$attr['type'] = intval( $attr['resource_id'] ); // FixIn: 10.2.2.2. |
| 870 |
} |
| 871 |
if ( isset( $attr['type'] ) ) { |
| 872 |
$my_boook_type = intval( $attr['type'] ); // FixIn: 10.2.2.2. |
| 873 |
} |
| 874 |
if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) { |
| 875 |
$additional_bk_types = $attr['agregate']; |
| 876 |
$my_boook_type .= ';'.$additional_bk_types; |
| 877 |
} |
| 878 |
if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) { // FixIn: 8.3.3.8. |
| 879 |
$additional_bk_types = $attr['aggregate']; |
| 880 |
$my_boook_type .= ';'.$additional_bk_types; |
| 881 |
} |
| 882 |
|
| 883 |
if ( isset( $attr['startmonth'] ) ) { // Set start month of calendar, fomrat: '2011-1' |
| 884 |
$start_month_calendar = explode( '-', $attr['startmonth'] ); |
| 885 |
if ( (is_array($start_month_calendar)) && ( count($start_month_calendar) > 1) ) { } |
| 886 |
else $start_month_calendar = false; |
| 887 |
} |
| 888 |
|
| 889 |
if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; } |
| 890 |
$res = $this->add_calendar_action($my_boook_type,$my_boook_count, 0, $start_month_calendar, $bk_otions ); |
| 891 |
|
| 892 |
|
| 893 |
$start_script_code = "<div id='calendar_booking_unselectable".$my_boook_type."'></div>"; |
| 894 |
return "<div class='wpbc_only_calendar wpbc_container'>" . $start_script_code . $res . '</div>'; // FixIn: 8.0.1.2. |
| 895 |
} |
| 896 |
|
| 897 |
// Show only booking form, with already selected dates |
| 898 |
function bookingform_shortcode($attr) { |
| 899 |
|
| 900 |
if ( wpbc_is_on_edit_page() ) { |
| 901 |
return wpbc_get_preview_for_shortcode( 'bookingform', $attr ); // FixIn: 9.9.0.39. |
| 902 |
} |
| 903 |
|
| 904 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 905 |
|
| 906 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 907 |
|
| 908 |
$my_boook_type = 1; |
| 909 |
$my_booking_form = 'standard'; |
| 910 |
$my_boook_count = 1; |
| 911 |
$my_selected_dates_without_calendar = ''; |
| 912 |
|
| 913 |
if ( isset( $attr['resource_id'] ) ) { |
| 914 |
$attr['type'] = intval( $attr['resource_id'] ); // FixIn: 10.2.2.2. |
| 915 |
} |
| 916 |
if ( isset( $attr['type'] ) ) { |
| 917 |
$my_boook_type = intval( $attr['type'] ); // FixIn: 10.2.2.2. |
| 918 |
} |
| 919 |
if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; } |
| 920 |
if ( isset( $attr['selected_dates'] ) ) { $my_selected_dates_without_calendar = $attr['selected_dates']; } //$my_selected_dates_without_calendar = '20.08.2010, 29.08.2010'; |
| 921 |
|
| 922 |
$res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, $my_selected_dates_without_calendar, false ); |
| 923 |
|
| 924 |
return $res; |
| 925 |
} |
| 926 |
|
| 927 |
|
| 928 |
// Show booking form for editing |
| 929 |
function bookingedit_shortcode($attr) { |
| 930 |
|
| 931 |
if ( wpbc_is_on_edit_page() ) { |
| 932 |
return wpbc_get_preview_for_shortcode( 'bookingedit', $attr ); // FixIn: 9.9.0.39. |
| 933 |
} |
| 934 |
|
| 935 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 936 |
|
| 937 |
|
| 938 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 939 |
|
| 940 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 941 |
if ( isset( $_GET['wpbc_hash'] ) ) { |
| 942 |
|
| 943 |
if ( function_exists( 'wpbc_parse_one_way_hash' ) ) { |
| 944 |
|
| 945 |
$get_wpbc_hash = ( ( isset( $_GET['wpbc_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['wpbc_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 946 |
|
| 947 |
$one_way_hash_response = wpbc_parse_one_way_hash( $get_wpbc_hash ); |
| 948 |
|
| 949 |
return $one_way_hash_response; |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
$my_boook_count = get_bk_option( 'booking_client_cal_count' ); |
| 954 |
$my_boook_type = 1; |
| 955 |
$my_booking_form = 'standard'; |
| 956 |
$bk_otions = array(); |
| 957 |
if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; } |
| 958 |
if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| 959 |
if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; } |
| 960 |
if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; } |
| 961 |
if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) { // FixIn: 7.0.1.26. |
| 962 |
$additional_bk_types = $attr['agregate']; |
| 963 |
$my_boook_type .= ';'.$additional_bk_types; |
| 964 |
} |
| 965 |
if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) { |
| 966 |
$additional_bk_types = $attr['aggregate']; |
| 967 |
$my_boook_type .= ';'.$additional_bk_types; |
| 968 |
} |
| 969 |
if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; } |
| 970 |
|
| 971 |
|
| 972 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 973 |
if (isset($_GET['booking_hash'])) { |
| 974 |
$get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 975 |
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash ); |
| 976 |
if ($my_booking_id_type !== false) { |
| 977 |
$my_edited_bk_id = $my_booking_id_type[0]; |
| 978 |
$my_boook_type = $my_booking_id_type[1]; |
| 979 |
if ($my_boook_type == '') return '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . esc_html__('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); |
| 980 |
} else { |
| 981 |
return '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . esc_html__('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); |
| 982 |
} |
| 983 |
|
| 984 |
} else { |
| 985 |
return __('This page can only be accessed through links in emails related to your booking.' ,'booking') |
| 986 |
. ' <br/><em>' |
| 987 |
/* translators: 1: ... */ |
| 988 |
. sprintf( __( 'Please check more about configuration at %1$sthis page%2$s', 'booking' ) |
| 989 |
, '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">' , '</a>.') |
| 990 |
. '</em>'; |
| 991 |
} |
| 992 |
|
| 993 |
|
| 994 |
$res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, '', false, $bk_otions ); |
| 995 |
|
| 996 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 997 |
if (isset($_GET['booking_pay'])) { |
| 998 |
// Payment form |
| 999 |
if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ // FixIn: 9.2.3.8. |
| 1000 |
make_bk_action('make_force_using_this_user', -999 ); // '-999' - This ID "by default" is the ID of super booking admin user |
| 1001 |
} |
| 1002 |
|
| 1003 |
$get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 1004 |
$res = wpbc_do_shortcode__booking_confirm( array( |
| 1005 |
'booking_hash' => $get_booking_hash |
| 1006 |
) ); |
| 1007 |
|
| 1008 |
if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ // FixIn: 9.2.3.8. |
| 1009 |
make_bk_action( 'finish_force_using_this_user' ); |
| 1010 |
} |
| 1011 |
|
| 1012 |
} |
| 1013 |
|
| 1014 |
return $res; |
| 1015 |
} |
| 1016 |
|
| 1017 |
// Search form |
| 1018 |
function bookingsearch_shortcode($attr) { |
| 1019 |
|
| 1020 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 1021 |
return '<strong>' . esc_html__( 'This shortcode available in Pro versions, only!', 'booking' ) . '</strong> '; |
| 1022 |
} |
| 1023 |
|
| 1024 |
if ( wpbc_is_on_edit_page() ) { |
| 1025 |
return wpbc_get_preview_for_shortcode( 'bookingsearch', $attr ); // FixIn: 9.9.0.39. |
| 1026 |
} |
| 1027 |
|
| 1028 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 1029 |
|
| 1030 |
$search_form = ''; |
| 1031 |
|
| 1032 |
if ( function_exists( 'wpbc_search_avy__show_search_form' ) ) { |
| 1033 |
|
| 1034 |
ob_start(); |
| 1035 |
|
| 1036 |
$search_form_content = wpbc_search_avy__show_search_form( $attr ); |
| 1037 |
|
| 1038 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1039 |
echo $search_form_content; |
| 1040 |
|
| 1041 |
$search_form = ob_get_clean(); |
| 1042 |
} |
| 1043 |
|
| 1044 |
return $search_form ; |
| 1045 |
} |
| 1046 |
|
| 1047 |
/** |
| 1048 |
* Search Results Shortcode -- Show 'Search Results' at New Page |
| 1049 |
* |
| 1050 |
* @param $attr |
| 1051 |
* |
| 1052 |
* @return string |
| 1053 |
*/ |
| 1054 |
function bookingsearchresults_shortcode($attr) { |
| 1055 |
|
| 1056 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 1057 |
return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> '; |
| 1058 |
} |
| 1059 |
|
| 1060 |
if ( wpbc_is_on_edit_page() ) { |
| 1061 |
return wpbc_get_preview_for_shortcode( 'bookingsearchresults', $attr ); // FixIn: 9.9.0.39. |
| 1062 |
} |
| 1063 |
|
| 1064 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 1065 |
|
| 1066 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 1067 |
|
| 1068 |
$search_results_to_show = ''; |
| 1069 |
if ( function_exists( 'wpbc_search_avy__show_search_results' ) ) { |
| 1070 |
|
| 1071 |
ob_start(); |
| 1072 |
|
| 1073 |
wpbc_search_avy__show_search_results( $attr ); // FixIn: 10.0.0.37. |
| 1074 |
|
| 1075 |
$search_results_to_show .= ob_get_clean(); |
| 1076 |
} |
| 1077 |
|
| 1078 |
return $search_results_to_show; |
| 1079 |
} |
| 1080 |
|
| 1081 |
|
| 1082 |
// Select Booking form using the selectbox |
| 1083 |
function bookingselect_shortcode($attr) { |
| 1084 |
|
| 1085 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 1086 |
return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> '; |
| 1087 |
} |
| 1088 |
|
| 1089 |
if ( wpbc_is_on_edit_page() ) { |
| 1090 |
return wpbc_get_preview_for_shortcode( 'bookingselect', $attr ); // FixIn: 9.9.0.39. |
| 1091 |
} |
| 1092 |
|
| 1093 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 1094 |
|
| 1095 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 1096 |
|
| 1097 |
$search_form = apply_bk_filter('wpdev_get_booking_select_form','', $attr ); |
| 1098 |
|
| 1099 |
return $search_form ; |
| 1100 |
} |
| 1101 |
|
| 1102 |
// Select Booking form using the selectbox |
| 1103 |
function bookingresource_shortcode($attr) { |
| 1104 |
|
| 1105 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 1106 |
return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> '; |
| 1107 |
} |
| 1108 |
|
| 1109 |
if ( wpbc_is_on_edit_page() ) { |
| 1110 |
return wpbc_get_preview_for_shortcode( 'bookingresource', $attr ); // FixIn: 9.9.0.39. |
| 1111 |
} |
| 1112 |
|
| 1113 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 1114 |
|
| 1115 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 1116 |
|
| 1117 |
$search_form = apply_bk_filter('wpbc_booking_resource_info','', $attr ); |
| 1118 |
|
| 1119 |
return $search_form ; |
| 1120 |
} |
| 1121 |
|
| 1122 |
|
| 1123 |
// </editor-fold> |
| 1124 |
} |