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 / core / lib / wpdev-booking-class.php

wpdev-booking-class.php in Booking Calendar 11.8, at core/lib/wpdev-booking-class.php

311 lines 12.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @file: wp-content/plugins/booking/core/lib/wpdev-booking-class.php
4 */
5 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
6
7 class wpdev_booking {
8
9 public $popover_front_end_js_is_writed; //FixIn: Flex TimeLine 1.0 -- previos this was private and not public property
10
11 // <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 ">
12
13 var $wpdev_bk_personal;
14
15 function __construct() {
16
17 $this->popover_front_end_js_is_writed = false;
18 $this->wpdev_bk_personal = false;
19
20 if ( class_exists( 'wpdev_bk_personal' ) ) {
21 $this->wpdev_bk_personal = new wpdev_bk_personal();
22 }
23
24 add_action( 'init', array( $this, 'wpbc_shortcodes_init' ), 9999 ); // <- priority to load it last
25 }
26 // </editor-fold>
27
28
29 /**
30 * S H O R T C O D E s Init
31 *
32 * @return void
33 */
34 function wpbc_shortcodes_init(){
35 add_shortcode( 'bookingedit', array( $this, 'bookingedit_shortcode' ) );
36 add_shortcode( 'bookingsearch', array( $this, 'bookingsearch_shortcode' ) );
37 add_shortcode( 'bookingsearchresults', array( $this, 'bookingsearchresults_shortcode' ) );
38 add_shortcode( 'bookingselect', array( $this, 'bookingselect_shortcode' ) );
39 add_shortcode( 'bookingresource', array( $this, 'bookingresource_shortcode' ) );
40 add_shortcode( 'bookingtimeline', array( $this, 'bookingtimeline_shortcode' ) );
41 add_shortcode( 'bookingcustomerlisting', array( $this, 'bookingcustomerlisting_shortcode' ) ); // FixIn: 8.1.3.5.
42 }
43
44
45 // <editor-fold defaultstate="collapsed" desc=" S H O R T C O D E S ">
46
47 // FixIn: 8.1.3.5.
48 /** Render verified customer access and the customer's booking list.
49 *
50 * @param array $attr Shortcode attributes.
51 *
52 * @return string Customer verification or booking-listing HTML.
53 */
54 function bookingcustomerlisting_shortcode( $attr ){
55
56 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
57 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
58 }
59
60 if ( wpbc_is_on_edit_page() ) {
61 return wpbc_get_preview_for_shortcode( 'bookingcustomerlisting', $attr ); // FixIn: 9.9.0.39.
62 }
63
64 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
65 $attr = is_array( $attr ) ? $attr : array();
66
67 if ( ! function_exists( 'wpbc_customer_bookings_render_shortcode' ) ) {
68 return '<strong>' . esc_html__( 'Customer booking access is temporarily unavailable.', 'booking' ) . '</strong>';
69 }
70
71 return wpbc_customer_bookings_render_shortcode( $attr );
72 }
73
74 /**
75 * TimeLine shortcode
76 *
77 * @param type $attr
78 *
79 * @return type
80 *
81 * Shortcodes exmaples:
82 *
83 *
84 ** Matrix:
85 * 1 Month View Mode:
86 * [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']
87 * 2 Months View Mode:
88 * [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']
89 * 1 Week View Mode:
90 * [bookingtimeline type="3,4" view_days_num=7 scroll_start_date="" scroll_day=-7 header_title='All Bookings']
91 * 1 Day View Mode:
92 * [bookingtimeline type="3,4" view_days_num=1 scroll_start_date="" scroll_day=0 header_title='All Bookings']
93 ** Single:
94 * 1 Month View Mode:
95 * [bookingtimeline type="4" view_days_num=30 scroll_start_date="" scroll_day=-15 scroll_month=0 header_title='All Bookings']
96 * 3 Months View Mode:
97 * [bookingtimeline type="4" view_days_num=90 scroll_start_date="" scroll_day=-30]
98 * 1 Year View Mode:
99 * [bookingtimeline type="4" view_days_num=365 scroll_start_date="" scroll_month=-3]
100 */
101 function bookingtimeline_shortcode($attr) {
102
103 if ( wpbc_is_on_edit_page() ) {
104 return wpbc_get_preview_for_shortcode( 'bookingtimeline', $attr ); // FixIn: 9.9.0.39.
105 }
106
107 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
108
109 // FixIn: 8.6.1.13.
110 $timeline_results = bookingflextimeline_shortcode($attr);
111 return $timeline_results;
112 }
113
114
115 // Show booking form for editing
116 function bookingedit_shortcode($attr) {
117
118 if ( wpbc_is_on_edit_page() ) {
119 return wpbc_get_preview_for_shortcode( 'bookingedit', $attr ); // FixIn: 9.9.0.39.
120 }
121
122 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
123
124
125 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
126
127 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
128 if ( isset( $_GET['wpbc_hash'] ) ) {
129
130 if ( function_exists( 'wpbc_parse_one_way_hash' ) ) {
131
132 $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 */
133
134 $one_way_hash_response = wpbc_parse_one_way_hash( $get_wpbc_hash );
135
136 return $one_way_hash_response;
137 }
138 }
139
140 $my_boook_count = get_bk_option( 'booking_client_cal_count' );
141 $my_boook_type = 1;
142 $my_booking_form = 'standard';
143 $shortcode_param__options = array();
144 if ( isset( $attr['nummonths'] ) ) { $my_boook_count = intval( $attr['nummonths'] ); }
145 if ( isset( $attr['resource_id'] ) ) { $attr['type'] = intval( $attr['resource_id']); }
146 if ( isset( $attr['type'] ) ) { $my_boook_type = intval( $attr['type']); }
147 if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
148 if ( isset( $attr['agregate'] ) && ( ! empty( $attr['agregate'] ) ) ) { // FixIn: 7.0.1.26.
149 $my_boook_type .= ';' . $attr['agregate'];
150 }
151 if ( isset( $attr['aggregate'] ) && ( ! empty( $attr['aggregate'] ) ) ) {
152 $my_boook_type .= ';' . $attr['aggregate'];
153 }
154 // Escape any XSS in aggregate parameter.
155 $my_boook_type = str_replace( ',', ';', wpbc_clean_digit_or_csd( $my_boook_type ) );
156
157 if ( isset( $attr['options'] ) ) { $shortcode_param__options = $attr['options']; }
158
159
160 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
161 if (isset($_GET['booking_hash'])) {
162 $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 */
163 $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash );
164 if ($my_booking_id_type !== false) {
165 $my_edited_bk_id = $my_booking_id_type[0];
166 $my_boook_type = $my_booking_id_type[1];
167 if ($my_boook_type == '') return '<div class="wpbc_after_booking_thank_you_section"><div class="wpbc_ty__container"><div class="wpbc_ty__header"><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') . '</div></div></div>';
168 } else {
169 return '<div class="wpbc_after_booking_thank_you_section"><div class="wpbc_ty__container"><div class="wpbc_ty__header"><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') . '</div></div></div>';
170 }
171
172 } else {
173 return __('This page can only be accessed through links in emails related to your booking.' ,'booking')
174 . ' <br/><em>'
175 /* translators: 1: ... */
176 . sprintf( __( 'Please check more about configuration at %1$sthis page%2$s', 'booking' )
177 , '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">' , '</a>.')
178 . '</em>';
179 }
180
181
182 $res = wpbc_get_rendered_booking_form_html($my_boook_type,$my_boook_count, 0 , $my_booking_form, '', false, $shortcode_param__options );
183
184 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
185 if (isset($_GET['booking_pay'])) {
186 // Payment form
187 if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ // FixIn: 9.2.3.8.
188 make_bk_action('make_force_using_this_user', -999 ); // '-999' - This ID "by default" is the ID of super booking admin user
189 }
190
191 $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 */
192 $res = wpbc_do_shortcode__booking_confirm( array(
193 'booking_hash' => $get_booking_hash
194 ) );
195
196 if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ // FixIn: 9.2.3.8.
197 make_bk_action( 'finish_force_using_this_user' );
198 }
199
200 }
201
202 return $res;
203 }
204
205 // Search form
206 function bookingsearch_shortcode($attr) {
207
208 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
209 return '<strong>' . esc_html__( 'This shortcode available in Pro versions, only!', 'booking' ) . '</strong> ';
210 }
211
212 if ( wpbc_is_on_edit_page() ) {
213 return wpbc_get_preview_for_shortcode( 'bookingsearch', $attr ); // FixIn: 9.9.0.39.
214 }
215
216 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
217
218 $search_form = '';
219
220 if ( function_exists( 'wpbc_search_avy__show_search_form' ) ) {
221
222 ob_start();
223
224 $search_form_content = wpbc_search_avy__show_search_form( $attr );
225
226 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
227 echo $search_form_content;
228
229 $search_form = ob_get_clean();
230 }
231
232 return $search_form ;
233 }
234
235 /**
236 * Search Results Shortcode -- Show 'Search Results' at New Page
237 *
238 * @param $attr
239 *
240 * @return string
241 */
242 function bookingsearchresults_shortcode($attr) {
243
244 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
245 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
246 }
247
248 if ( wpbc_is_on_edit_page() ) {
249 return wpbc_get_preview_for_shortcode( 'bookingsearchresults', $attr ); // FixIn: 9.9.0.39.
250 }
251
252 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
253
254 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
255
256 $search_results_to_show = '';
257 if ( function_exists( 'wpbc_search_avy__show_search_results' ) ) {
258
259 ob_start();
260
261 wpbc_search_avy__show_search_results( $attr ); // FixIn: 10.0.0.37.
262
263 $search_results_to_show .= ob_get_clean();
264 }
265
266 return $search_results_to_show;
267 }
268
269 // Select Booking form using the selectbox
270 function bookingselect_shortcode($attr) {
271
272 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
273 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
274 }
275
276 if ( wpbc_is_on_edit_page() ) {
277 return wpbc_get_preview_for_shortcode( 'bookingselect', $attr ); // FixIn: 9.9.0.39.
278 }
279
280 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
281
282 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
283
284 $search_form = apply_bk_filter('wpdev_get_booking_select_form','', $attr );
285
286 return $search_form ;
287 }
288
289 // Select Booking form using the selectbox
290 function bookingresource_shortcode($attr) {
291
292 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
293 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
294 }
295
296 if ( wpbc_is_on_edit_page() ) {
297 return wpbc_get_preview_for_shortcode( 'bookingresource', $attr ); // FixIn: 9.9.0.39.
298 }
299
300 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
301
302 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
303
304 $search_form = apply_bk_filter('wpbc_booking_resource_info','', $attr );
305
306 return $search_form ;
307 }
308
309 // </editor-fold>
310 }
311