PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
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 10.11.2 All 203 releases
← All changes | core/wpbc_functions.php +658 -3200 10.1.311.8.3 View file →
@@ -13,586 +13,104 @@
13 13 */
14 14
15 15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16 16
17 + /**
18 + * Get Logo for conversation.
19 + *
20 + * @param string $svg_color - main color.
21 + * @param string $svg_color_alt - alt color.
22 + *
23 + * @return void
24 + */
25 + function wpbc_get_svg_logo( $svg_color = '#000', $svg_color_alt = '#fff', $opacity = '0.1' ) {
17 26
27 +// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="150 150 850 850">'
28 +// . '<path style="fill:' . $svg_color . '" d="M224.3 117.81c0-7.62 6.18-13.8 13.8-13.8h104.13c7.62 0 13.8 6.18 13.8 13.8v239.06c-58.48 32.03-105.14 82.96-131.74 144.58V117.81z"/>'
29 +// . '<path style="fill:' . $svg_color . ';" d="M224.3 620.3c0-152.27 123.43-275.7 275.7-275.7 69.48 0 132.95 25.7 181.43 68.11l-93.55 93.55c-24.31-18.76-54.79-29.92-87.88-29.92-79.51 0-143.96 64.45-143.96 143.96S420.49 764.26 500 764.26c33.09 0 63.57-11.16 87.88-29.92l93.55 93.55C632.95 870.3 569.48 896 500 896c-152.27 0-275.7-123.44-275.7-275.7z"/>'
30 +// . '<path style="fill:' . $svg_color_alt . '" fill-opacity="' . $opacity . '" d="m681.43 827.89-93.55-93.55c34.11-26.33 56.08-67.62 56.08-114.04s-21.97-87.71-56.08-114.04l93.55-93.55c57.78 50.54 94.27 124.8 94.27 207.59s-36.49 157.05-94.27 207.59z"/>'
31 +// . '</svg>';
32 +//
33 +//
34 +// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" version="1.1" viewBox="0 0 600 600">
35 +// <path id="O_Letter" d="M298.22 197.55c-92.32 0-167.15 77.82-167.15 173.81s74.84 173.82 167.15 173.82 167.15-77.82 167.15-173.82-74.84-173.81-167.15-173.81Zm0 264.53c-50.1 0-90.71-40.61-90.71-90.71s40.61-90.71 90.71-90.71 90.71 40.61 90.71 90.71-40.61 90.71-90.71 90.71Z" style="fill:' . $svg_color_alt . ';" fill-opacity="' . $opacity . '" />
36 +// <path id="C_Letter" d="M363.75 434.1c-14.85 15.51-35.16 25.76-57.84 27.66-54.87 4.6-101.64-41.14-98.23-96.1 2.94-47.44 42.35-85.01 90.54-85.01 24.84 0 47.34 9.98 63.72 26.16 5.86 5.78 15.29 5.73 21.11-.09l35.14-35.14c5.69-5.69 5.9-14.87.43-20.77-30.41-32.83-73.1-53.26-120.4-53.26-92.32 0-167.15 77.82-167.15 173.81s74.84 173.82 167.15 173.82c48.49 0 92.15-21.47 122.68-55.76 5.29-5.94 5.02-14.97-.6-20.59l-35.05-35.05c-5.98-5.98-15.67-5.79-21.51.32Z" style="fill:' . $svg_color . ';"/>
37 +// <path d="M130.69 357.28v2.59c0 .27.06.53.17.76a123.1 123.1 0 0 1-.17-3.35Zm4.51-50.82c12.34-39.07 38.32-70.02 77.79-97.04.92-.63 1.48-1.67 1.48-2.79V59.95c0-4.28-3.68-7.76-8.22-7.76h-3.76c-18.56 0-73.17 40.3-71.79 60.62l-.17 192.91c0 2.74 3.86 3.34 4.68.73Z" style="fill:' . $svg_color . ';"/>
38 +// </svg>';
39 +//
40 +// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
41 +// <path d="M311.92 214.22c-92.32 0-167.15 77.82-167.15 173.81s74.84 173.82 167.15 173.82 167.15-77.82 167.15-173.82-74.84-173.81-167.15-173.81Zm0 264.53c-50.1 0-90.71-40.61-90.71-90.71s40.61-90.71 90.71-90.71 90.71 40.61 90.71 90.71-40.61 90.71-90.71 90.71Z" style="fill:' . $svg_color_alt . ';" fill-opacity="' . $opacity . '" />
42 +// <path d="M377.45 450.77c-14.85 15.51-35.16 25.76-57.84 27.66-54.87 4.6-101.64-41.14-98.23-96.1 2.94-47.44 42.35-85.01 90.54-85.01 24.84 0 47.34 9.98 63.72 26.16 5.86 5.78 15.29 5.73 21.11-.09l35.14-35.14c5.69-5.69 5.9-14.87.43-20.77-30.41-32.83-73.1-53.26-120.4-53.26-92.32 0-167.15 77.82-167.15 173.81s74.84 173.82 167.15 173.82c48.49 0 92.15-21.47 122.68-55.76 5.29-5.94 5.02-14.97-.6-20.59l-35.05-35.05c-5.98-5.98-15.67-5.79-21.51.32Z" style="fill:' . $svg_color . ';"/>
43 +// <path d="M149.45 318.12c12.34-39.07 38.32-70.02 77.79-97.04.92-.63 1.48-1.67 1.48-2.79V71.62c0-4.28-3.68-7.76-8.22-7.76h-3.76c-18.56 0-73.17 40.3-71.79 60.62l-.17 192.91c0 2.74 3.86 3.34 4.68.73Z" style="fill:' . $svg_color . ';"/>
44 +// </svg>';
45 +//
46 +// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
47 +// <path d="M275 176.36c-92.32 0-167.15 77.82-167.15 173.81S182.69 523.99 275 523.99s167.15-77.82 167.15-173.82S367.31 176.36 275 176.36Zm0 264.53c-50.1 0-90.71-40.61-90.71-90.71s40.61-90.71 90.71-90.71 90.71 40.61 90.71 90.71-40.61 90.71-90.71 90.71Z" style="fill:#ffd25b"/>
48 +// <path d="M340.53 412.91c-14.85 15.51-35.16 25.76-57.84 27.66-54.87 4.6-101.64-41.14-98.23-96.1 2.94-47.44 42.35-85.01 90.54-85.01 24.84 0 47.34 9.98 63.72 26.16 5.86 5.78 15.29 5.73 21.11-.09l35.14-35.14c5.69-5.69 5.9-14.87.43-20.77-30.41-32.83-73.1-53.26-120.4-53.26-92.32 0-167.15 77.82-167.15 173.81S182.69 523.99 275 523.99c48.49 0 92.15-21.47 122.68-55.76 5.29-5.94 5.02-14.97-.6-20.59l-35.05-35.05c-5.98-5.98-15.67-5.79-21.51.32Z" style="fill:#193db2"/>
49 +// <path d="M112.53 280.27c12.34-39.07 38.32-70.02 77.79-97.04.92-.63 1.48-1.67 1.48-2.79V33.76c0-4.28-3.68-7.76-8.22-7.76h-3.76c-18.56 0-73.17 40.3-71.79 60.62l-.17 192.91c0 2.74 3.86 3.34 4.68.73Z" style="fill:#451fff"/>
50 +// </svg>';
18 51
52 + // FixIn: 10.11.3.3.
53 + $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">'
54 + . '<path d="M275 162.36c-92.32 0-167.15 77.82-167.15 173.81S182.69 509.99 275 509.99s167.15-77.82 167.15-173.82S367.31 162.36 275 162.36Zm0 264.53c-50.1 0-90.71-40.61-90.71-90.71s40.61-90.71 90.71-90.71 90.71 40.61 90.71 90.71-40.61 90.71-90.71 90.71Z" style="fill:' . $svg_color_alt . ';" fill-opacity="' . $opacity . '" />'
55 + . '<path d="M340.53 398.91c-14.85 15.51-35.16 25.76-57.84 27.66-54.87 4.6-101.64-41.14-98.23-96.1 2.94-47.44 42.35-85.01 90.54-85.01 24.84 0 47.34 9.98 63.72 26.16 5.86 5.78 15.29 5.73 21.11-.09l35.14-35.14c5.69-5.69 5.9-14.87.43-20.77-30.41-32.83-73.1-53.26-120.4-53.26-92.32 0-167.15 77.82-167.15 173.81S182.69 509.99 275 509.99c48.49 0 92.15-21.47 122.68-55.76 5.29-5.94 5.02-14.97-.6-20.59l-35.05-35.05c-5.98-5.98-15.67-5.79-21.51.32Z" style="fill:' . $svg_color . ';"/>'
56 + . '<path d="M112.53 261.27c12.34-39.07 38.32-70.02 77.79-97.04.92-.63 1.48-1.67 1.48-2.79V14.76c0-4.28-3.68-7.76-8.22-7.76h-3.76c-18.56 0-73.17 40.3-71.79 60.62l-.17 192.91c0 2.74 3.86 3.34 4.68.73Z" style="fill:' . $svg_color . ';"/>'
57 + . '</svg>';
19 58
20 - // <editor-fold defaultstate="collapsed" desc=" == Booking details | replace / fields functions == " >
21 59
22 - /**
23 - * Get booking resource title (translated/localized)
24 - *
25 - * @param $resource_id
26 - *
27 - * @return string
28 - */
29 - function wpbc_get_resource_title( $resource_id = 1 ) {
60 + return $svg_icon_integarted;
61 + }
30 62
31 - $resource_title = '';
32 63
33 - if ( function_exists( 'wpbc_db__get_resource_title' ) ) {
64 + /**
65 + * Get Logo for Background Image.
66 + *
67 + * @param string $svg_color - main color.
68 + * @param string $svg_color_alt - alt color.
69 + *
70 + * @return void
71 + */
72 + function wpbc_get_svg_logo_for_background( $svg_color = '#000', $svg_color_alt = '#fff', $opacity = '0.2' ) {
34 73
35 - $resource_title = wpbc_db__get_resource_title( $resource_id );
74 + $svg_icon_integarted = wpbc_get_svg_logo( $svg_color, $svg_color_alt, $opacity );
36 75
37 - if (! empty($resource_title)) {
38 - $resource_title = wpbc_lang( $resource_title );
39 - }
40 - }
76 + $svg_icon_integarted = sprintf( 'data:image/svg+xml;base64,%s', base64_encode( $svg_icon_integarted ) );
41 77
42 - return $resource_title;
43 - }
78 + return $svg_icon_integarted;
79 + }
44 80
81 + /**
82 + * Get Logo as HTML element.
83 + *
84 + * @param array $params - logo parameters.
85 + *
86 + * @return string
87 + */
88 + function wpbc_get_svg_logo_for_html( $params = array() ) {
45 89
46 - /**
47 - * Check, if exist booking for this hash. If existed, get Email of this booking
48 - *
49 - * @param string $booking_hash - booking hash.
50 - * @param string $booking_data_key - booking field key - default 'email'.
51 - *
52 - * @return bool - booking data field
53 - */
54 - function wpbc_get__booking_data_field__by_booking_hash( $booking_hash, $booking_data_key = 'email' ){ //FixIn: 8.1.3.5
90 + // FixIn: 10.12.1.6.
91 + $defaults = array(
92 + 'svg_color' => '#ccc',
93 + 'svg_color_alt' => '#aaa',
94 + 'opacity' => '0.4',
95 + 'style_default' => 'background-repeat: no-repeat; background-position: center; display: inline-block; vertical-align: top;',
96 + 'style_adjust' => 'background-size: 18px auto; width: 20px; height: 20px; margin-top: 6px;', // This parameters, the adjust size of the logo and position.
97 + 'css_class' => '',
98 + );
55 99
56 - $return_val = false;
100 + $params = wp_parse_args( $params, $defaults );
57 101
58 - // $booking_hash = '0d55671fd055fd64423294f89d6b58e6'; // debugging
102 + $svg_logo_for_background = wpbc_get_svg_logo_for_background( $params['svg_color'], $params['svg_color_alt'], $params['opacity'] );
59 103
60 - if ( ! empty( $booking_hash ) ) {
104 + $svg_icon_integarted = '<i';
105 + $svg_icon_integarted .= ' class="wpbc_svg_logo ' . esc_attr( $params['css_class'] ) . '"';
106 + $svg_icon_integarted .= ' style="' . esc_attr( $params['style_default'] ) . esc_attr( $params['style_adjust'] );
107 + $svg_icon_integarted .= 'background-image: url(\'' . esc_attr( $svg_logo_for_background ) . '\') !important;"';
108 + $svg_icon_integarted .= '></i>';
61 109
62 - $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $booking_hash );
110 + return $svg_icon_integarted;
111 + }
63 112
64 - if ( ! empty( $my_booking_id_type ) ) {
65 -
66 - list( $booking_id, $resource_id ) = $my_booking_id_type;
67 -
68 - $booking_data = wpbc_db_get_booking_details( $booking_id );
69 -
70 - if ( ! empty( $booking_data ) ) {
71 -
72 - $booking_details = wpbc_get_booking_different_params_arr( $booking_id, $booking_data->form, $resource_id );
73 -
74 - if ( isset( $booking_details[ $booking_data_key ] ) ) {
75 -
76 - $return_val = $booking_details[ $booking_data_key ];
77 - }
78 - }
79 - }
80 - }
81 - return $return_val;
82 - }
83 -
84 -
85 - /**
86 - * Get booking details object from DB
87 - *
88 - * @param $booking_id - int
89 - *
90 - * @return mixed - booking details or false if not found
91 - * Example:
92 - * stdClass Object
93 - * (
94 - * [booking_id] => 26
95 - * [trash] => 0
96 - * [sync_gid] =>
97 - * [is_new] => 0
98 - * [status] =>
99 - * [sort_date] => 2018-02-27 00:00:00
100 - * [modification_date] => 2018-02-18 12:49:30
101 - * [form] => text^selected_short_dates_hint3^02/27/2018 - 03/02/2018~text^days_number_hint3^4~text^cost_hint3^40.250&nbsp;&#36;~text^name3^Victoria~text^secondname3^vica~email^email3^vica@wpbookingcalendar.com~text^phone3^test booking ~selectbox-one^visitors3^1
102 - * [hash] => 0d55671fd055fd64423294f89d6b58e6
103 - * [booking_type] => 3
104 - * [remark] =>
105 - * [cost] => 40.25
106 - * [pay_status] => 151895097121.16
107 - * [pay_request] => 0
108 - * )
109 - */
110 - function wpbc_db_get_booking_details( $booking_id ){ //FixIn: 8.1.3.5
111 -
112 - global $wpdb;
113 -
114 - $slct_sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}booking WHERE booking_id = %d LIMIT 0,1", $booking_id );
115 -
116 - $sql_results = $wpdb->get_row( $slct_sql );
117 -
118 - if ( ! empty( $sql_results ) ) {
119 - return $sql_results;
120 - } else {
121 - return false;
122 - }
123 - }
124 -
125 -
126 - /**
127 - * Get booking D a t e s from DB - array of objects
128 - *
129 - * @param $booking_id - int
130 - *
131 - * @return mixed - booking dates array or false if not found
132 - *
133 - */
134 - function wpbc_db_get_booking_dates( $booking_id ){
135 -
136 - global $wpdb;
137 -
138 - $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}bookingdates as dt WHERE dt.booking_id = %d ", $booking_id );
139 -
140 - if ( class_exists( 'wpdev_bk_biz_l' ) ) {
141 - $sql .= " ORDER BY booking_id, type_id, booking_date ";
142 - } else {
143 - $sql .= " ORDER BY booking_id, booking_date ";
144 - }
145 -
146 - $sql_results = $wpdb->get_results( $sql );
147 -
148 - if ( ! empty( $sql_results ) ) {
149 - return $sql_results;
150 - } else {
151 - return false;
152 - }
153 - }
154 -
155 -
156 - /**
157 - * Get booking modification date from DB
158 - * @param $booking_id
159 - *
160 - * @return string
161 - */
162 - function wpbc_db_get_booking_modification_date( $booking_id ){ //FixIn: 8.0.1.7
163 - global $wpdb;
164 - $modification_date = ' ' . $wpdb->get_var( $wpdb->prepare( "SELECT modification_date FROM {$wpdb->prefix}booking WHERE booking_id = %d " , $booking_id ) );
165 - return $modification_date;
166 - }
167 -
168 -
169 - /**
170 - * Get user IP
171 - *
172 - * @return mixed|string
173 - */
174 - function wpbc_get_user_ip() {
175 -
176 - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
177 - $userIP = $_SERVER['HTTP_CLIENT_IP'];
178 - } elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
179 - $userIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
180 - } elseif ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) {
181 - $userIP = $_SERVER['HTTP_X_FORWARDED'];
182 - } elseif ( isset( $_SERVER['HTTP_FORWARDED_FOR'] ) ) {
183 - $userIP = $_SERVER['HTTP_FORWARDED_FOR'];
184 - } elseif ( isset( $_SERVER['HTTP_FORWARDED'] ) ) {
185 - $userIP = $_SERVER['HTTP_FORWARDED'];
186 - } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
187 - $userIP = $_SERVER['REMOTE_ADDR'];
188 - } else {
189 - $userIP = "";
190 - }
191 - return $userIP;
192 - }
193 -
194 - /**
195 - * Get IP of Server
196 - *
197 - * @return string
198 - */
199 - function wpbc_get_server_ip() { //FixIn: 9.8.14.3
200 -
201 - $ip_address = '';
202 - if ( array_key_exists( 'SERVER_ADDR', $_SERVER ) ) {
203 - $ip_address = $_SERVER['SERVER_ADDR'];
204 - } else if ( array_key_exists( 'LOCAL_ADDR', $_SERVER ) ) {
205 - $ip_address = $_SERVER['LOCAL_ADDR'];
206 - }
207 -
208 - return $ip_address;
209 - }
210 -
211 - /**
212 - * Get different Booking Fields as array for replace
213 - *
214 - * @param int $booking_id - ID of booking // 999
215 - * @param string $formdata - booking form data content // selectbox-one^rangetime4^10:00 - 12:00~text^name4^Jo~text^secondname4^Smith~email^email4^smith@wpbookingcalendar.com~...
216 - * @param int $booking_resource_id - booking resource type // 4
217 - *
218 - * @return array
219 - *
220 - * Example:
221 - * [
222 - * [booking_id] => 26
223 - * [id] => 26
224 - * [days_input_format] => 01.03.2018,02.03.2018,27.02.2018,28.02.2018
225 - * [days_only_sql] => 2018-02-27,2018-02-28,2018-03-01,2018-03-02
226 - * [dates_sql] => 2018-02-27 00:00:00, 2018-02-28 00:00:00, 2018-03-01 00:00:00, 2018-03-02 00:00:00
227 - * [check_in_date_sql] => 2018-02-27 00:00:00
228 - * [check_out_date_sql] => 2018-03-02 00:00:00
229 - * [dates] => 02/27/2018 - 03/02/2018
230 - * [check_in_date] => 02/27/2018
231 - * [check_out_date] => 03/02/2018
232 - * [check_out_plus1day] => 03/03/2018
233 - * [dates_count] => 4
234 - * [days_count] => 4
235 - * [nights_count] => 3
236 - * [check_in_date_hint] => 02/27/2018
237 - * [check_out_date_hint] => 03/02/2018
238 - * [start_time_hint] => 00:00
239 - * [end_time_hint] => 00:00
240 - * [selected_dates_hint] => 02/27/2018, 02/28/2018, 03/01/2018, 03/02/2018
241 - * [selected_timedates_hint] => 02/27/2018, 02/28/2018, 03/01/2018, 03/02/2018
242 - * [selected_short_dates_hint] => 02/27/2018 - 03/02/2018
243 - * [selected_short_timedates_hint] => 02/27/2018 - 03/02/2018
244 - * [days_number_hint] => 4
245 - * [nights_number_hint] => 3
246 - * [siteurl] => http://beta
247 - * [resource_title] => Apartment A
248 - * [bookingtype] => Apartment A
249 - * [remote_ip] => 127.0.0.1
250 - * [user_agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
251 - * [request_url] => http://beta/wp-admin/post.php?post=1473&action=edit
252 - * [current_date] => 02/18/2018
253 - * [current_time] => 14:11
254 - * [cost_hint] => 40.250 $
255 - * [name] => Victoria
256 - * [secondname] => vica
257 - * [email] => vica@wpbookingcalendar.com
258 - * [phone] => test booking
259 - * [visitors] => 1
260 - * [booking_resource_id] => 3
261 - * [resource_id] => 3
262 - * [type_id] => 3
263 - * [type] => 3
264 - * [resource] => 3
265 - * [content] => '........'
266 - * [moderatelink] => http://beta/wp-admin/admin.php?page=wpbc&view_mode=vm_listing&tab=actions&wh_booking_id=26
267 - * [visitorbookingediturl] => http://beta/?booking_hash=0d55671fd055fd64423294f89d6b58e6
268 - * [visitorbookingcancelurl] => http://beta/?booking_hash=0d55671fd055fd64423294f89d6b58e6&booking_cancel=1
269 - * [visitorbookingpayurl] => http://beta/?booking_hash=0d55671fd055fd64423294f89d6b58e6&booking_pay=1
270 - * [bookinghash] => 0d55671fd055fd64423294f89d6b58e6
271 - * [db_cost] => 40.25
272 - * [db_cost_hint] => 40.250 $
273 - * [modification_date] => 2018-02-18 12:49:30
274 - * [modification_year] => 2018
275 - * [modification_month] => 02
276 - * [modification_day] => 18
277 - * [modification_hour] => 12
278 - * [modification_minutes] => 49
279 - * [modification_seconds] => 30
280 - * ]
281 - */
282 - function wpbc_get_booking_different_params_arr( $booking_id, $formdata, $booking_resource_id = 1 ) {
283 -
284 - $replace = array();
285 -
286 - // Resources ///////////////////////////////////////////////////////////////
287 - $bk_title = wpbc_get_resource_title( $booking_resource_id );
288 -
289 -
290 - ////////////////////////////////////////////////////////////////////////////
291 - // Dates Dif. Formats
292 - ////////////////////////////////////////////////////////////////////////////
293 -
294 - // -> '2023-10-09 12:00:01, 2023-10-09 20:00:02'
295 - $sql_dates_format = wpbc_db__get_sql_dates__in_booking__as_str( $booking_id ); // 2016-08-03 16:00:01, 2016-08-03 18:00:02
296 -
297 - $sql_dates_only = explode(',',$sql_dates_format);
298 - $sql_days_only_array = array();
299 - $days_as_in_form_array = array();
300 - foreach ( $sql_dates_only as $sql_day_only ) {
301 - $sql_days_only_array[] = trim( substr($sql_day_only, 0, 11 ) );
302 - $days_as_in_form_array[] = date_i18n( "d.m.Y", strtotime( trim( substr($sql_day_only, 0, 11 ) ) ) );
303 - }
304 - $sql_days_only_array = array_unique( $sql_days_only_array );
305 - sort( $sql_days_only_array );
306 - $sql_days_only = implode( ',', $sql_days_only_array );
307 -
308 - $days_as_in_form_array = array_unique( $days_as_in_form_array );
309 - sort( $days_as_in_form_array );
310 - $days_as_in_form = implode( ',', $days_as_in_form_array );
311 -
312 - $sql_days_only_with_full_times = array();
313 - foreach ( $sql_days_only_array as $sql_day ) {
314 - $sql_days_only_with_full_times[] = $sql_day . ' 00:00:00';
315 - }
316 - $sql_days_only_with_full_times = implode(',', $sql_days_only_with_full_times );
317 -
318 -
319 - if ( get_bk_option( 'booking_date_view_type' ) == 'short' ) {
320 - $formated_booking_dates = wpbc_get_dates_short_format( $sql_dates_format );
321 - } else {
322 - $formated_booking_dates = wpbc_get_dates_comma_string_localized( $sql_dates_format );
323 - }
324 -
325 - $sql_dates_format_check_in_out = explode(',', $sql_dates_format );
326 -
327 - $my_check_in_date = wpbc_get_dates_comma_string_localized( $sql_dates_format_check_in_out[0] );
328 - $my_check_out_date = wpbc_get_dates_comma_string_localized( $sql_dates_format_check_in_out[ count( $sql_dates_format_check_in_out ) - 1 ] );
329 -
330 - $my_check_out_plus1day = wpbc_datetime_localized( date( 'Y-m-d H:i:s'
331 - , strtotime( $sql_dates_format_check_in_out[ count( $sql_dates_format_check_in_out ) - 1 ]
332 - . " +1 day" )
333 - ) );
334 -
335 - $date_format = get_bk_option( 'booking_date_format');
336 - $check_in_date_hint = wpbc_date_localized( $sql_days_only_array[0] );
337 - $check_out_date_hint = wpbc_date_localized( $sql_days_only_array[ ( count( $sql_days_only_array ) - 1 ) ] );
338 -
339 - //FixIn: 9.7.3.16
340 - $cancel_date_hint = wpbc_datetime_localized( date( 'Y-m-d H:i:s'
341 - , strtotime( '-14 days', strtotime( $sql_days_only_array[0] ) )
342 - ) );
343 - //FixIn: 10.0.0.31
344 - $pre_checkin_date_hint = wpbc_datetime_localized( date( 'Y-m-d H:i:s'
345 - , strtotime( '-' . intval( get_bk_option( 'booking_number_for_pre_checkin_date_hint' ) ) . ' days', strtotime( $sql_days_only_array[0] ) )
346 - ) );
347 -
348 - // Booking Times -------------------------------------------------------------------------------------------
349 - $start_end_time = wpbc_get_times_in_form( $formdata, $booking_resource_id ); // false ||
350 -
351 - if ( $start_end_time !== false ) {
352 - $start_time = $start_end_time[0]; // array('00','00','01');
353 - $end_time = $start_end_time[1]; // array('00','00','01');
354 - } else {
355 - $start_time = array('00','00','00');
356 - $end_time = array('00','00','00');
357 - }
358 -
359 -//TODO: continue here with replacing date_i18n to wpbc_loc_ ...
360 -
361 - $start_time_hint = wpbc_time_localized( implode( ':', $start_time ) );
362 - $end_time_hint = wpbc_time_localized( implode( ':', $end_time ) );
363 -
364 - //FixIn: 9.5.1.3
365 - $check_in_date_sql = wpbc_date_localized( $sql_days_only_array[0], 'Y-m-d' );
366 - $check_out_date_sql = wpbc_date_localized( $sql_days_only_array[ ( count( $sql_days_only_array ) - 1 ) ], 'Y-m-d' );
367 -
368 - $start_time_sql = wpbc_time_localized( implode( ':', $start_time ), 'H:i' );
369 - $end_time_sql = wpbc_time_localized( implode( ':', $end_time ) , 'H:i' );
370 -
371 - ////////////////////////////////////////////////////////////////////////////
372 -
373 -
374 - // Other ///////////////////////////////////////////////////////////////////
375 - $replace[ 'booking_id' ] = $booking_id;
376 - $replace[ 'id' ] = $replace[ 'booking_id' ];
377 -
378 - $replace[ 'days_input_format' ] = $days_as_in_form; // 15.11.2023,16.11.2023,17.11.2023
379 - $replace[ 'days_only_sql' ] = $sql_days_only; // 2023-11-15,2023-11-16,2023-11-17
380 - $replace[ 'dates_sql' ] = $sql_dates_format; // 2016-07-28 16:00:01, 2016-07-28 18:00:02
381 - $replace[ 'check_in_date_sql' ] = $sql_dates_format_check_in_out[0]; // 2016-07-28 16:00:01
382 - $replace[ 'check_out_date_sql' ] = $sql_dates_format_check_in_out[ count( $sql_dates_format_check_in_out ) - 1 ]; // 2016-07-28 18:00:02
383 - $replace[ 'dates' ] = $formated_booking_dates; // July 28, 2016 16:00 - July 28, 2016 18:00
384 - $replace[ 'check_in_date' ] = $my_check_in_date; // July 28, 2016 16:00
385 - $replace[ 'check_out_date' ] = $my_check_out_date; // July 28, 2016 18:00
386 - $replace[ 'check_out_plus1day'] = $my_check_out_plus1day; // July 29, 2016 18:00
387 - $replace[ 'dates_count' ] = count( $sql_days_only_array ); // 1
388 - $replace[ 'days_count' ] = count( $sql_days_only_array ); // 1
389 - $replace[ 'nights_count' ] = ( $replace[ 'days_count' ] > 1 ) ? ( $replace[ 'days_count' ] - 1 ) : $replace[ 'days_count' ]; // 1
390 -
391 - //FixIn: 9.7.3.16
392 - $replace[ 'cancel_date_hint' ] = $cancel_date_hint; // 11/11/2013
393 - //FixIn: 10.0.0.31
394 - $replace[ 'pre_checkin_date_hint' ] = $pre_checkin_date_hint; // 11/11/2013
395 -
396 - $replace[ 'check_in_date_hint' ] = $check_in_date_hint; // 11/25/2013
397 - $replace[ 'check_out_date_hint' ] = $check_out_date_hint; // 11/27/2013
398 - $replace[ 'start_time_hint' ] = $start_time_hint; // 10:00
399 - $replace[ 'end_time_hint' ] = $end_time_hint; // 12:00
400 -
401 - //FixIn: 9.5.1.3
402 - $replace['check_in_date_hint_sql'] = $check_in_date_sql; // 2023-03-04
403 - $replace['check_out_date_hint_sql'] = $check_out_date_sql; // 2023-03-12
404 - $replace['start_time_hint_sql'] = $start_time_sql; // 10:00
405 - $replace['end_time_hint_sql'] = $end_time_sql; // 12:00
406 -
407 - $replace['selected_dates_hint'] = wpbc_get_dates_comma_string_localized( $sql_days_only_with_full_times ); // 11/25/2013, 11/26/2013, 11/27/2013
408 - $replace['selected_timedates_hint'] = wpbc_get_dates_comma_string_localized( $sql_dates_format ); // 11/25/2013 10:00, 11/26/2013, 11/27/2013 12:00
409 - $replace['selected_short_dates_hint'] = wpbc_get_dates_short_format( $sql_days_only_with_full_times ); // 11/25/2013 - 11/27/2013
410 - $replace['selected_short_timedates_hint'] = wpbc_get_dates_short_format( $sql_dates_format ); // 11/25/2013 10:00 - 11/27/2013 12:00
411 - $replace[ 'days_number_hint' ] = $replace[ 'days_count' ]; // 3
412 - $replace[ 'nights_number_hint' ] = $replace[ 'nights_count' ]; // 2
413 - $replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . home_url() . '">' . home_url() . '</a>' );
414 - $replace[ 'resource_title'] = wpbc_lang( $bk_title );
415 - $replace[ 'bookingtype' ] = $replace[ 'resource_title'];
416 - $replace[ 'remote_ip' ] = wpbc_get_user_ip(); // The IP address from which the user is viewing the current page.
417 - $replace[ 'user_agent' ] = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : ''; // Contents of the User-Agent: header from the current request, if there is one.
418 - $replace[ 'request_url' ] = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ''; // The address of the page (if any) where action was occured. Because we are sending it in Ajax request, we need to use the REFERER HTTP
419 - $replace[ 'current_date' ] = date_i18n( get_bk_option( 'booking_date_format' ) );
420 - $replace[ 'current_time' ] = date_i18n( get_bk_option( 'booking_time_format' ) );
421 -
422 -
423 - // Form Fields /////////////////////////////////////////////////////////////
424 - $booking_form_show_array = wpbc__legacy__get_form_content_arr( $formdata, $booking_resource_id, '', $replace ); // We use here $replace array, becaise in "Content of booking filds data" form can be shortcodes from above definition
425 -
426 - foreach ( $booking_form_show_array['_all_fields_'] as $shortcode_name => $shortcode_value ) {
427 -
428 - if ( ! isset( $replace[ $shortcode_name ] ) )
429 - $replace[ $shortcode_name ] = $shortcode_value;
430 - }
431 - $replace[ 'content' ] = $booking_form_show_array['content'];
432 -
433 - // Links ///////////////////////////////////////////////////////////////////
434 - $replace[ 'moderatelink' ] = htmlspecialchars_decode(
435 - // '<a href="' .
436 - esc_url( wpbc_get_bookings_url() . '&view_mode=vm_listing&tab=actions&wh_booking_id=' . $booking_id )
437 - // . '">' . __('here', 'booking') . '</a>'
438 - );
439 - $replace[ 'visitorbookingediturl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingediturl]', $booking_id );
440 - $replace[ 'visitorbookingslisting' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingslisting]', $booking_id ); //FixIn: 8.1.3.5.1
441 - $replace[ 'visitorbookingcancelurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingcancelurl]', $booking_id );
442 - $replace[ 'visitorbookingpayurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingpayurl]', $booking_id );
443 - $replace[ 'bookinghash' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[bookinghash]', $booking_id );
444 -
445 - // Cost ////////////////////////////////////////////////////////////////////
446 - $replace[ 'db_cost' ] = apply_bk_filter( 'get_booking_cost_from_db', '', $booking_id );
447 - $replace[ 'db_cost_hint' ] = wpbc_get_cost_with_currency_for_user( $replace[ 'db_cost' ], $booking_resource_id );
448 -
449 - ////////////////////////////////////////////////////////////////////////////
450 -
451 - //FixIn: 8.0.1.7
452 - $modification_date = wpbc_db_get_booking_modification_date( $booking_id );
453 -
454 - // This date $values in GMT date/Time format. So we need to switch to WordPress locale with TIME sum of actual GMT date/time value + shift of timezone from WordPress.
455 - $is_add_wp_timezone = true;
456 - $modification_date = wpbc_datetime_localized( trim( $modification_date ), 'Y-m-d H:i:s', $is_add_wp_timezone );
457 - $replace['modification_date'] = ' ' . $modification_date;
458 - $modification_date = explode( ' ', $modification_date );
459 - list( $replace['modification_year'], $replace['modification_month'], $replace['modification_day'] ) = explode( '-', $modification_date[0] );
460 - list( $replace['modification_hour'], $replace['modification_minutes'], $replace['modification_seconds'] ) = explode( ':', $modification_date[1] );
461 -
462 - //FixIn: 10.0.0.34
463 - if ( ! empty( $replace['creation_date'] ) ) {
464 -
465 - // This date $values in GMT date/Time format. So we need to switch to WordPress locale with TIME sum of actual GMT date/time value + shift of timezone from WordPress.
466 - $creation_date = wpbc_datetime_localized( trim( $replace['creation_date'] ), 'Y-m-d H:i:s', $is_add_wp_timezone );
467 -
468 - $replace['creation_date'] = ' ' . $creation_date;
469 - $creation_date = explode( ' ', $creation_date );
470 - list( $replace['creation_year'], $replace['creation_month'], $replace['creation_day'] ) = explode( '-', $creation_date[0] );
471 - list( $replace['creation_hour'], $replace['creation_minutes'], $replace['creation_seconds'] ) = explode( ':', $creation_date[1] );
472 - }
473 -
474 - return $replace;
475 - }
476 -
477 -
478 - /**
479 - * Get additional parameters to the replace array for specific booking
480 - *
481 - * @param $replace
482 - * @param $booking_id
483 - * @param $bktype
484 - * @param $formdata
485 - *
486 - * @return mixed
487 - */
488 - function wpbc_replace_params_for_booking_func( $replace, $booking_id, $bktype, $formdata ){
489 - /*
490 - $modification_date = wpbc_db_get_booking_modification_date( $booking_id );
491 -
492 - // This date $values in GMT date/Time format. So we need to switch to WordPress locale with TIME sum of actual GMT date/time value + shift of timezone from WordPress.
493 - $is_add_wp_timezone = true;
494 - $modification_date = wpbc_datetime_localized( trim( $modification_date ), 'Y-m-d H:i:s', $is_add_wp_timezone );
495 -
496 - $replace['modification_date'] = ' ' . $modification_date;
497 -
498 - $modification_date = explode( ' ', $modification_date );
499 - list( $replace['modification_year'], $replace['modification_month'], $replace['modification_day'] ) = explode( '-', $modification_date[0] );
500 - list( $replace['modification_hour'], $replace['modification_minutes'], $replace['modification_seconds'] ) = explode( ':', $modification_date[1] );
501 - */
502 -
503 - //FixIn: 8.4.2.11
504 - if ( isset( $replace['rangetime'] ) ) {
505 - $replace['rangetime'] = wpbc_time_slot_in_format( $replace['rangetime'] );
506 - }
507 - if ( isset( $replace['starttime'] ) ) {
508 - $replace['starttime'] = wpbc_time_in_format( $replace['starttime'] );
509 - }
510 - if ( isset( $replace['endtime'] ) ) {
511 - $replace['endtime'] = wpbc_time_in_format( $replace['endtime'] );
512 - }
513 -
514 - //FixIn: 8.2.1.25
515 - $booking_data = wpbc_db_get_booking_details( $booking_id );
516 -
517 - if ( ! empty( $booking_data ) ) {
518 - foreach ( $booking_data as $booking_key => $booking_data ) {
519 - if ( ! isset( $replace[ $booking_key ] ) ) {
520 - $replace[ $booking_key ] = $booking_data;
521 - }
522 - }
523 - }
524 -
525 - // Set dates and times in correct format ---------------------------------------------------------------
526 -
527 - $is_add_wp_timezone = true;
528 -
529 - if ( ! empty( $replace['modification_date'] ) ) {
530 -
531 - // This date $values in GMT date/Time format. So we need to switch to WordPress locale with TIME sum of actual GMT date/time value + shift of timezone from WordPress.
532 - $modification_date = wpbc_datetime_localized( trim( $replace['modification_date'] ), 'Y-m-d H:i:s', $is_add_wp_timezone );
533 -
534 - $replace['modification_date'] = ' ' . $modification_date;
535 - $modification_date = explode( ' ', $modification_date );
536 - list( $replace['modification_year'], $replace['modification_month'], $replace['modification_day'] ) = explode( '-', $modification_date[0] );
537 - list( $replace['modification_hour'], $replace['modification_minutes'], $replace['modification_seconds'] ) = explode( ':', $modification_date[1] );
538 - }
539 - //FixIn: 10.0.0.34
540 - if ( ! empty( $replace['creation_date'] ) ) {
541 -
542 - // This date $values in GMT date/Time format. So we need to switch to WordPress locale with TIME sum of actual GMT date/time value + shift of timezone from WordPress.
543 - $creation_date = wpbc_datetime_localized( trim( $replace['creation_date'] ), 'Y-m-d H:i:s', $is_add_wp_timezone );
544 -
545 - $replace['creation_date'] = ' ' . $creation_date;
546 - $creation_date = explode( ' ', $creation_date );
547 - list( $replace['creation_year'], $replace['creation_month'], $replace['creation_day'] ) = explode( '-', $creation_date[0] );
548 - list( $replace['creation_hour'], $replace['creation_minutes'], $replace['creation_seconds'] ) = explode( ':', $creation_date[1] );
549 - }
550 -
551 - return $replace;
552 - }
553 - add_filter( 'wpbc_replace_params_for_booking', 'wpbc_replace_params_for_booking_func', 10, 4 );
554 -
555 -
556 - /**
557 - * Replace shortcodes in string
558 - *
559 - * @param string $subject - string to manipulate
560 - * @param array $replace_array - array with values to replace // array( [booking_id] => 9, [id] => 9, [dates] => July 3, 2016 14:00 - July 4, 2016 16:00, .... )
561 - * @param mixed $replace_unknown_shortcodes - replace unknown params, if false, then no replace unknown params
562 - * @return string
563 - */
564 - function wpbc_replace_booking_shortcodes( $subject, $replace_array , $replace_unknown_shortcodes = ' ' ) {
565 -
566 - $defaults = array(
567 - 'ip' => wpbc_get_user_ip()
568 - , 'blogname' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
569 - , 'siteurl' => get_site_url()
570 - );
571 -
572 - $replace = wp_parse_args( $replace_array, $defaults );
573 -
574 - foreach ( $replace as $replace_shortcode => $replace_value ) {
575 -
576 - $subject = str_replace( array( '[' . $replace_shortcode . ']'
577 - , '{' . $replace_shortcode . '}' )
578 - , $replace_value
579 - , $subject );
580 - }
581 -
582 - // Remove all shortcodes, which is not replaced early.
583 - if ( $replace_unknown_shortcodes !== false )
584 - $subject = preg_replace( '/[\s]{0,}[\[\{]{1}[a-zA-Z0-9.,-_]{0,}[\]\}]{1}[\s]{0,}/', $replace_unknown_shortcodes, $subject );
585 -
586 -
587 - return $subject;
588 - }
589 -
590 -
591 -
592 - // </editor-fold>
593 -
594 -
595 113 // <editor-fold defaultstate="collapsed" desc=" == Get html preview of shortcode for Edit pages == " >
596 114
597 115 /**
598 116 * Get html preview of shortcode for Edit pages in Elementor and at Block editors
@@ -603,9 +121,9 @@
603 121 * @return string
604 122 */
605 123 function wpbc_get_preview_for_shortcode( $shortcode_type, $attr ) {
606 124
607 - //FixIn: 9.9.0.39
125 + // FixIn: 9.9.0.39.
608 126
609 127 return '<div style="border:2px dashed #ccc;text-align: center; padding:10px;display:flex;flex-flow:column wrap;justify-content: center;align-content: center;">
610 128 <div>WP Booking Calendar Shortcode</div>
611 129 <code>['.$shortcode_type.' ...]</code>
@@ -614,413 +132,8 @@
614 132 }
615 133 // </editor-fold>
616 134
617 135
618 - // <editor-fold defaultstate="collapsed" desc=" == Get version Nums or Types == " >
619 -
620 - /**
621 - * Check if this demo website
622 - *
623 - * @return bool
624 - */
625 - function wpbc_is_this_demo() {
626 -
627 -// return !true;
628 - if ( ! class_exists( 'wpdev_bk_personal' ) ) {
629 - return false; // If this is Booking Calendar Free version, then it's not the demo.
630 - }
631 -
632 - //FixIn: 7.2.1.17
633 - if (
634 - ( ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'wpbookingcalendar.com' ) !== false ) )
635 - || ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( strpos( $_SERVER['HTTP_HOST'], 'wpbookingcalendar.com' ) !== false ) )
636 - ) {
637 - return true;
638 - } else {
639 - return false;
640 - }
641 - }
642 -
643 -
644 - /**
645 - * Check if this Beta Demo website
646 - *
647 - * @return bool
648 - */
649 - function wpbc_is_this_beta() {
650 -
651 - $is_beta = ( $_SERVER['HTTP_HOST'] === 'beta' );
652 -
653 - return $is_beta;
654 - }
655 -
656 -
657 - /** Get Warning Text for Demo websites */
658 - function wpbc_get_warning_text_in_demo_mode() {
659 - // return '<div class="wpbc-error-message wpbc_demo_test_version_warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>'; //Old Style
660 - return '<div class="wpbc-settings-notice notice-warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>';
661 - }
662 -
663 -
664 -
665 - function wpbc_get_version_type__and_mu(){
666 - $version = 'free';
667 - if ( class_exists( 'wpdev_bk_personal' ) ) $version = 'personal';
668 - if ( class_exists( 'wpdev_bk_biz_s' ) ) $version = 'biz_s';
669 - if ( class_exists( 'wpdev_bk_biz_m' ) ) $version = 'biz_m';
670 - if ( class_exists( 'wpdev_bk_biz_l' ) ) $version = 'biz_l';
671 - if ( class_exists('wpdev_bk_multiuser') ) $version = 'multiuser';
672 - return $version;
673 - }
674 -
675 -
676 - function wpbc_get_plugin_version_type(){
677 - $version = 'free';
678 - if ( class_exists( 'wpdev_bk_personal' ) ) $version = 'personal';
679 - if ( class_exists( 'wpdev_bk_biz_s' ) ) $version = 'biz_s';
680 - if ( class_exists( 'wpdev_bk_biz_m' ) ) $version = 'biz_m';
681 - if ( class_exists( 'wpdev_bk_biz_l' ) ) $version = 'biz_l';
682 - return $version;
683 - }
684 -
685 -
686 - /**
687 - * Check if user accidentially update Booking Calendar Paid version to Free
688 - *
689 - * @return bool
690 - */
691 - function wpbc_is_updated_paid_to_free() {
692 -
693 - if ( ( wpbc_is_table_exists('bookingtypes') ) && ( ! class_exists('wpdev_bk_personal') ) )
694 - return true;
695 - else
696 - return false;
697 - }
698 -
699 -
700 - function wpbc_get_ver_sufix() {
701 - if( strpos( strtolower(WPDEV_BK_VERSION) , 'multisite') !== false ) {
702 - $v_type = '-multi';
703 - } else if( strpos( strtolower(WPDEV_BK_VERSION) , 'develop') !== false ) {
704 - $v_type = '-dev';
705 - } else {
706 - $v_type = '';
707 - }
708 - $v = '';
709 - if (class_exists('wpdev_bk_personal')) $v = 'ps'. $v_type;
710 - if (class_exists('wpdev_bk_biz_s')) $v = 'bs'. $v_type;
711 - if (class_exists('wpdev_bk_biz_m')) $v = 'bm'. $v_type;
712 - if (class_exists('wpdev_bk_biz_l')) $v = 'bl'. $v_type;
713 - if (class_exists('wpdev_bk_multiuser')) $v = '';
714 - return $v ;
715 - }
716 -
717 -
718 - function wpbc_up_link() {
719 - if ( ! wpbc_is_this_demo() )
720 - $v = wpbc_get_ver_sufix();
721 - else $v = '';
722 - return 'https://wpbookingcalendar.com/' . ( ( empty($v) ) ? '' : 'upgrade-' . $v . '/' ) ;
723 - }
724 -
725 -
726 - /**
727 - * Check if "Booking Manager" installed/activated and return version number
728 - *
729 - * @return string - 0 if not installed, otherwise version num
730 - */
731 - function wpbc_get_wpbm_version() {
732 -
733 - if ( ! defined( 'WPBM_VERSION_NUM' ) ) {
734 - return 0;
735 - } else {
736 - return WPBM_VERSION_NUM;
737 - }
738 - }
739 -
740 -
741 - /**
742 - * Get header info from this file, just for compatibility with WordPress 2.8 and older versions
743 - *
744 - * @param $file = WPBC_FILE
745 - * @param $default_headers = array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' )
746 - * @param $context = 'plugin'
747 - *
748 - * @return array
749 - *
750 - * Example:
751 - * $plugin_data = wpbc_file__read_header_info( WPBC_FILE , array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' ) , 'plugin' );
752 - */
753 - function wpbc_file__read_header_info( $file, $default_headers, $context = '' ) {
754 -
755 - $fp = fopen( $file, 'r' ); // We don't need to write to the file, so just open for reading.
756 -
757 - $file_data = fread( $fp, 8192 ); // Pull only the first 8kiB of the file in.
758 -
759 - fclose( $fp ); // PHP will close file handle, but we are good citizens.
760 -
761 - if ( $context != '' ) {
762 - $extra_headers = array(); //apply_filters( "extra_$context".'_headers', array() );
763 -
764 - $extra_headers = array_flip( $extra_headers );
765 - foreach ( $extra_headers as $key => $value ) {
766 - $extra_headers[ $key ] = $key;
767 - }
768 - $all_headers = array_merge( $extra_headers, $default_headers );
769 - } else {
770 - $all_headers = $default_headers;
771 - }
772 -
773 - foreach ( $all_headers as $field => $regex ) {
774 - preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
775 - if ( !empty( ${$field} ) )
776 - ${$field} = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', ${$field}[1] ));
777 - else
778 - ${$field} = '';
779 - }
780 -
781 - $file_data = compact( array_keys( $all_headers ) );
782 -
783 - return $file_data;
784 - }
785 -
786 -
787 -
788 - /**
789 - * Check if we need BLUR this section -- add CSS Class for specific versions
790 - *
791 - * Example: $is_blured = wpbc_is_blured( array( 'free', 'ps' ) ); // true in Free and Personal versions.
792 - *
793 - * @param $versions_arr
794 - *
795 - * @return void
796 - */
797 - function wpbc_is_blured( $versions_arr ){
798 -
799 - $ver = wpbc_get_version_type__and_mu();
800 -
801 - $is_blured = false;
802 -
803 - switch ( $ver ) {
804 - case 'free':
805 - $is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'f', $versions_arr ) ) ) ? true : $is_blured;
806 - break;
807 - case 'personal':
808 - $is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'ps', $versions_arr ) ) ) ? true : $is_blured;
809 - break;
810 - case 'biz_s':
811 - $is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'bs', $versions_arr ) ) ) ? true : $is_blured;
812 - break;
813 - case 'biz_m':
814 - $is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'bm', $versions_arr ) ) ) ? true : $is_blured;
815 - break;
816 - case 'biz_l':
817 - $is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'bl', $versions_arr ) ) ) ? true : $is_blured;
818 - break;
819 - case 'multiuser':
820 - $is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'mu', $versions_arr ) ) ) ? true : $is_blured;
821 - break;
822 - default:
823 - // Default
824 - }
825 - return $is_blured;
826 - }
827 -
828 -
829 - /**
830 - * Echo Blur CSS Class for specific versions
831 - *
832 - * Example: wpbc_echo_blur(array('free','ps')); // Echo blur in Free and Personal versions.
833 - *
834 - * @param $versions_arr
835 - *
836 - * @return void
837 - */
838 - function wpbc_echo_blur( $versions_arr ){
839 -
840 - $is_blured = wpbc_is_blured( $versions_arr );
841 -
842 - if ( $is_blured ) {
843 - echo 'wpbc_blur';
844 - }
845 - }
846 -
847 -
848 - /**
849 - * Show Upgrade Widget
850 - *
851 - * @param $id
852 - * @param $params
853 - *
854 - * @return string if upgrade panel hided than returned ''
855 - *
856 - *
857 - * Example:
858 - * wpbc_get_up_notice('booking_weekdays_conditions', array(
859 - * 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ),
860 - * 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
861 - * 'versions' => 'Business Large, MultiUser versions',
862 - * 'css' => 'transform: translate(0) translateY(120px);'
863 - * ));
864 - */
865 - function wpbc_get__upgrade_notice__html_content( $id, $params ){
866 -
867 - $defaults = array(
868 - 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ),
869 - 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
870 - 'versions' => 'Business Large, MultiUser versions',
871 - 'css' => 'transform: translate(0) translateY(120px);',
872 - 'dismiss_css_class' => '',
873 - 'html_dismiss_btn' => ''
874 - );
875 - $params = wp_parse_args( $params, $defaults );
876 -
877 - ob_start();
878 -
879 - ?><div id="upgrade_notice_<?php echo esc_attr( $id ); ?>"
880 - class="wpbc_widget_content wpbc_upgrade_widget <?php echo esc_attr( str_replace( array('.','#'), '', $params['dismiss_css_class'] ) ); ?>"
881 - style="<?php echo esc_attr( $params['css'] ); ?>">
882 - <div class="ui_container ui_container_toolbar ui_container_small wpbc_upgrade_widget_container">
883 - <div class="ui_group ui_group__upgrade">
884 - <div class="wpbc_upgrade_note wpbc_upgrade_theme_green">
885 - <div>
886 - <?php
887 - printf( 'This %s is available in the %s. %s'
888 - , '<a target="_blank" href="https://wpbookingcalendar.com/' . $params['feature_link']['relative_url'] . '">' . $params['feature_link']['title'] . '</a>'
889 - , '<strong>' . $params['versions'] . '</strong>'
890 - , '<a target="_blank" href="https://wpbookingcalendar.com/' . $params['upgrade_link']['relative_url'] . '">' . $params['upgrade_link']['title'] . '</a>'
891 - );
892 - ?>
893 - </div>
894 - <?php
895 - // Dismiss button
896 - echo $params['html_dismiss_btn'];
897 - ?>
898 - </div>
899 - </div>
900 - </div>
901 - </div><?php
902 -
903 - $html = ob_get_clean();
904 -
905 - return $html ;
906 - }
907 -
908 -
909 -
910 - /**
911 - * Get for showing Upgrade Widget Content and CSS class if needed to blur real content. If
912 - *
913 - * @param $params = array(
914 - * 'id' => $id . '_' . 'weekdays_conditions',
915 - * 'dismiss_css_class' => '.wpbc_dismiss_weekdays_conditions',
916 - * 'blured_in_versions' => array( 'free', 'ps', 'bs', 'mu' ),
917 - * 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#advanced-days-selection' ),
918 - * 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
919 - * 'versions' => 'Business Medium / Large, MultiUser versions',
920 - * 'css' => 'transform: translate(0) translateY(120px);'
921 - * )
922 - *
923 - * @return array(
924 - * 'content' => $upgrade_panel_html,
925 - * 'maybe_blur_css_class' => $blur_css_class
926 - * )
927 - *
928 - * Example of usage:
929 - *
930 - * $upgrade_content_arr = wpbc_get_upgrade_widget( array(
931 - * 'id' => $id . '_' . 'weekdays_conditions',
932 - * 'dismiss_css_class' => '.wpbc_dismiss_weekdays_conditions',
933 - * 'blured_in_versions' => array( 'free', 'ps', 'bs', 'mu' ),
934 - * 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#advanced-days-selection' ),
935 - * 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
936 - * 'versions' => 'Business Medium / Large, MultiUser versions',
937 - * 'css' => 'transform: translate(0) translateY(120px);'
938 - * ) );
939 - *
940 - * echo $upgrade_content_arr['content'];
941 - *
942 - * // ... In real content ...
943 - * <div class=" wpbc_dismiss_weekdays_conditions <?php echo esc_attr( $upgrade_content_arr['maybe_blur_css_class'] ); ?>">
944 - * ...
945 - * </div>
946 - */
947 - function wpbc_get_upgrade_widget( $params ) {
948 -
949 - $defaults = array(
950 - 'id' => 'wpbc_random_' . round( microtime( true ) * 1000 ), //$id . '_' . 'weekdays_conditions',
951 - 'blured_in_versions' => array( 'free', 'ps', 'bs', 'bm', 'bl', 'mu' ),
952 - 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ),
953 - 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
954 - 'versions' => 'Business Large, MultiUser versions',
955 - 'css' => 'transform: translate(0) translateY(120px);',
956 - 'dismiss_css_class' => '' //'.wpbc_random_' . round( microtime( true ) * 1000 ), //'.'.$id . '_' . 'weekdays_conditions'
957 - );
958 - $params = wp_parse_args( $params, $defaults );
959 - $up_id = $params['id'];
960 -
961 -
962 - $is_blured = wpbc_is_blured( $params['blured_in_versions'] );
963 -
964 - $upgrade_panel_html = '';
965 - $blur_css_class = '';
966 -
967 - if ( $is_blured ) {
968 -
969 - // ---------------------------------------------------------------------------------------------------------
970 - // Is dismissed ?
971 - // ---------------------------------------------------------------------------------------------------------
972 - ob_start();
973 - $is_upgrade_panel_visible = wpbc_is_dismissed( $up_id , array(
974 - 'title' => '<span aria-hidden="true" style="font-size: 28px;">&times;</span>',
975 - 'hint' => __( 'Dismiss', 'booking' ),
976 - 'class' => 'wpbc_panel_get_started_dismiss',
977 - 'css' => '',
978 - 'dismiss_css_class' => $params['dismiss_css_class']
979 - ) );
980 - $html_dismiss_btn = ob_get_clean();
981 -
982 - // ---------------------------------------------------------------------------------------------------------
983 - // Upgrade Widget
984 - // ---------------------------------------------------------------------------------------------------------
985 - if ( $is_upgrade_panel_visible ) {
986 -
987 - $upgrade_panel_html = wpbc_get__upgrade_notice__html_content( $up_id, array(
988 - 'feature_link' => $params['feature_link'],
989 - 'upgrade_link' => $params['upgrade_link'],
990 - 'versions' => $params['versions'],
991 - 'css' => $params['css'],
992 - 'dismiss_css_class' => $params['dismiss_css_class'],
993 - 'html_dismiss_btn'=> $html_dismiss_btn
994 - ) );
995 - $blur_css_class = 'wpbc_blur';
996 - } else {
997 -
998 - ob_start();
999 -
1000 - ?><script type="text/javascript">
1001 - jQuery(document).ready(function(){
1002 - setTimeout(function(){
1003 - jQuery( '<?php echo esc_attr( $params['dismiss_css_class'] ); ?>' ).hide() ;
1004 - }, 100);
1005 - });
1006 - </script><?php
1007 -
1008 - $upgrade_panel_html = ob_get_clean();
1009 - }
1010 - }
1011 -
1012 - $upgrade_content_arr = array(
1013 - 'content' => $upgrade_panel_html,
1014 - 'maybe_blur_css_class' => $blur_css_class
1015 - );
1016 -
1017 - return $upgrade_content_arr;
1018 -
1019 - }
1020 - // </editor-fold>
1021 -
1022 -
1023 136 // <editor-fold defaultstate="collapsed" desc=" == Calendar functions == " >
1024 137
1025 138 /**
1026 139 * Get maximum visible days in calendar
@@ -1032,14 +145,14 @@
1032 145 // Number of months to scroll
1033 146 $max_visible_days_in_calendar = get_bk_option( 'booking_max_monthes_in_calendar');
1034 147
1035 148 if ( false !== strpos( $max_visible_days_in_calendar, 'm' ) ) {
1036 - //$max_visible_days_in_calendar = intval( str_replace( 'm', '', $max_visible_days_in_calendar ) ) * 31 ; //FixIn: 9.6.1.1
1037 - //FixIn: 10.0.0.26
149 + //$max_visible_days_in_calendar = intval( str_replace( 'm', '', $max_visible_days_in_calendar ) ) * 31 ; // FixIn: 9.6.1.1.
150 + // FixIn: 10.0.0.26.
1038 151 $diff_days = strtotime( '+' . intval( str_replace( 'm', '', $max_visible_days_in_calendar ) ) . ' months', strtotime( 'now' ) ) - strtotime( 'now' );
1039 152 $max_visible_days_in_calendar = round( $diff_days / ( 60 * 60 * 24 ) ) + 1;
1040 153 } else {
1041 - $max_visible_days_in_calendar = intval( str_replace( 'y', '', $max_visible_days_in_calendar ) ) * 365 + 15; //FixIn: 9.6.1.1
154 + $max_visible_days_in_calendar = intval( str_replace( 'y', '', $max_visible_days_in_calendar ) ) * 365 + 15; // FixIn: 9.6.1.1.
1042 155 }
1043 156
1044 157 return $max_visible_days_in_calendar;
1045 158 }
@@ -1115,9 +228,9 @@
1115 228 * @param $bk_options
1116 229 *
1117 230 * @return array|false
1118 231 */
1119 - function wpbc_parse_calendar_options__aggregate_param( $bk_options ) { //FixIn: 9.8.15.10
232 + function wpbc_parse_calendar_options__aggregate_param( $bk_options ) { // FixIn: 9.8.15.10.
1120 233
1121 234 if ( empty( $bk_options ) ) {
1122 235 return false;
1123 236 }
@@ -1160,8 +273,133 @@
1160 273
1161 274 return false; // We are not have the "calendar" options in the shortcode
1162 275 }
1163 276
277 +
278 + function wpbc_is_calendar_skin_legacy( $skin_name ){
279 + $legacy_skins = array(
280 + 'black.css',
281 + 'multidays.css',
282 + 'premium-black.css',
283 + 'premium-light-noborder.css',
284 + 'premium-light.css',
285 + 'premium-marine.css',
286 + 'premium-steel-noborder.css',
287 + 'premium-steel.css',
288 + 'standard.css',
289 + 'traditional-light.css',
290 + 'traditional.css'
291 + // FixIn: 10.7.1.5.
292 + , 'traditional-times.css'
293 + , 'black-2.css'
294 + , 'green-01.css'
295 + , 'light-01.css'
296 + );
297 +
298 + return in_array( $skin_name, $legacy_skins );
299 + }
300 +
301 +
302 + /**
303 + * Get Legacy calendar skin
304 + *
305 + * @param $skin_name = 'Black-2'
306 + * @param $skin_arr = ["24_9__dark_1.css", "/css/skins/blac...", "Black-2"]
307 + *
308 + * @return mixed
309 + */
310 + function wpbc_get_legacy_calendar_skin_name($skin_name, $skin_arr){
311 +
312 + if (wpbc_is_calendar_skin_legacy($skin_arr[0]) ){
313 + return __( 'Legacy', 'booking' ) . ': ' . $skin_name;
314 + } else {
315 + return $skin_name;
316 + }
317 + }
318 +
319 + /**
320 + * Get Calendar skin options for selectboxes
321 + * @return void
322 + */
323 + function wpbc_get_calendar_skin_options( $url_prefix = '' ){
324 + // Calendar Skin /////////////////////////////////////////////////////
325 + $calendar_skins_options = array();
326 + $legacy_calendar_skins_options = array();
327 + // Skins in the Custom User folder (need to create it manually): http://example.com/wp-content/uploads/wpbc_skins/ ( This folder do not owerwrited during update of plugin )
328 + $upload_dir = wp_upload_dir();
329 + // FixIn: 8.9.4.8.
330 + $files_in_folder = wpbc_dir_list( array( WPBC_PLUGIN_DIR . '/css/skins/' ) ); // Folders where to look about calendar skins
331 + foreach ( $files_in_folder as $skin_file ) { // Example: $skin_file['/css/skins/standard.css'] => 'Standard';
332 +
333 + //FixIn: 8.9.4.8 // FixIn: 9.1.2.10.
334 + $skin_file[1] = str_replace( array( WPBC_PLUGIN_DIR, WPBC_PLUGIN_URL , $upload_dir['basedir'] ), '', $skin_file[1] ); // Get relative path for calendar skin
335 +
336 + if ( ! wpbc_is_calendar_skin_legacy( $skin_file[0] ) ) {
337 + $calendar_skins_options[ $skin_file[1] ] = $skin_file[2];
338 + } else {
339 + $legacy_calendar_skins_options[ $skin_file[1] ] = wpbc_get_legacy_calendar_skin_name( $skin_file[2], $skin_file );
340 + }
341 + }
342 +
343 + $calendar_skins_options_real = array();
344 + $calendar_skins_options_real[] = array( 'optgroup' => true, 'close' => false, 'title' => '&nbsp;' . __('Calendar Skins' ,'booking') );
345 + foreach ( $calendar_skins_options as $s_key => $s_val ) {
346 + $calendar_skins_options_real [ $url_prefix . $s_key ] = $s_val;
347 + }
348 + $calendar_skins_options_real[] = array( 'optgroup' => true, 'close' => true );
349 + $calendar_skins_options_real[] = array( 'optgroup' => true, 'close' => false, 'title' => '&nbsp;' . __('Legacy Calendar Skins' ,'booking') );
350 + foreach ( $legacy_calendar_skins_options as $s_key => $s_val ) {
351 + $calendar_skins_options_real [ $url_prefix . $s_key ] = array( 'title' => $s_val, 'attr' => array( 'style' => 'color:#ccc;' ) );
352 + }
353 + $calendar_skins_options_real[] = array( 'optgroup' => true, 'close' => true );
354 + $calendar_skins_options_real[] = array( 'optgroup' => true, 'close' => false, 'title' => '&nbsp;' . __('Custom Calendar Skins' ,'booking') );
355 + $files_in_folder = wpbc_dir_list( array( $upload_dir['basedir'].'/wpbc_skins/' ) ); // Folders where to look about calendar skins
356 + foreach ( $files_in_folder as $skin_file ) { // Example: $skin_file['/css/skins/standard.css'] => 'Standard';
357 +
358 + //FixIn: 8.9.4.8 // FixIn: 9.1.2.10.
359 + $skin_file[1] = str_replace( array( WPBC_PLUGIN_DIR, WPBC_PLUGIN_URL , $upload_dir['basedir'] ), '', $skin_file[1] ); // Get relative path for calendar skin
360 +
361 + $calendar_skins_options_real[ $url_prefix . $skin_file[1] ] = $skin_file[2];
362 +
363 + }
364 +
365 + $calendar_skins_options_real[] = array( 'optgroup' => true, 'close' => true );
366 +
367 + return $calendar_skins_options_real;
368 + }
369 +
370 +
371 + function wpbc_get_calendar_skin_options_with_legacy_sections(){
372 +
373 + // FixIn: 10.3.0.5.
374 + // Calendar Skin /////////////////////////////////////////////////////
375 + $cal_arr = wpbc_get_calendar_skin_options( WPBC_PLUGIN_URL );
376 +
377 + $upload_dir = wp_upload_dir(); // Check if this skin exist in the Custom User folder at the http://example.com/wp-content/uploads/wpbc_skins/
378 + $custom_user_skin_folder = $upload_dir['basedir'];
379 + $custom_user_skin_url = $upload_dir['baseurl'];
380 +
381 + $transformed_cal_arr = array();
382 + foreach ( $cal_arr as $calendar_skin_url => $calendar_name ) {
383 + if ( false !== strpos( $calendar_skin_url, WPBC_PLUGIN_URL ) ) {
384 +
385 + $relative_cal_skin_path = str_replace( WPBC_PLUGIN_URL, '', $calendar_skin_url );
386 +
387 + if ( file_exists( $custom_user_skin_folder . $relative_cal_skin_path ) ) {
388 + // Custom Skin
389 + $transformed_cal_arr[ $custom_user_skin_url . $relative_cal_skin_path ] = $calendar_name;
390 + } else {
391 + // Plugin Usual Skins
392 + $transformed_cal_arr[ WPBC_PLUGIN_URL . $relative_cal_skin_path ] = $calendar_name;
393 + }
394 + } else {
395 + // OptGroups
396 + $transformed_cal_arr[ $calendar_skin_url ] = $calendar_name;
397 + }
398 + }
399 +
400 + return $transformed_cal_arr;
401 + }
1164 402 // </editor-fold>
1165 403
1166 404
1167 405 // <editor-fold defaultstate="collapsed" desc=" == Files functions == " >
@@ -1238,9 +476,9 @@
1238 476 $d = 0; // string bytes counter
1239 477
1240 478 // Iterate over every character in the string, escaping with a slash or encoding to UTF-8 where necessary
1241 479 for ( $c = 0; $c < $strlen_var; ++ $c ) {
1242 - $ord_var_c = ord( $str[$c] ); //FixIn: 2.0.17.1
480 + $ord_var_c = ord( $str[$c] ); // FixIn: 2.0.17.1.
1243 481 switch ( true ) {
1244 482 case(($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): // characters U-00000000 - U-0000007F (same as ASCII)
1245 483 $d ++;
1246 484 break;
@@ -1269,471 +507,8 @@
1269 507
1270 508 // </editor-fold>
1271 509
1272 510
1273 - // <editor-fold defaultstate="collapsed" desc=" == URL functions == " >
1274 -
1275 - /**
1276 - * Get absolute URL to relative plugin path.
1277 - * Possibly to load minified version of file, if its exist
1278 - * @param string $path - path
1279 - * @return string
1280 - */
1281 - function wpbc_plugin_url( $path ) {
1282 -
1283 - return trailingslashit( WPBC_PLUGIN_URL ) . ltrim( $path, '/\\' );
1284 -
1285 - }
1286 -
1287 - // Set URL from absolute to relative (starting from /)
1288 - function wpbc_set_relative_url( $url ){
1289 -
1290 - $url = esc_url_raw($url);
1291 -
1292 - $url_path = parse_url($url, PHP_URL_PATH);
1293 - $url_path = ( empty($url_path) ? $url : $url_path );
1294 -
1295 - $url = trim($url_path, '/');
1296 - return '/' . $url;
1297 - }
1298 -
1299 - /**
1300 - * Get Relative URL
1301 - *
1302 - * @param $maybe_absolute_link
1303 - *
1304 - * @return string
1305 - */
1306 - function wpbc_make_link_relative( $maybe_absolute_link ) {
1307 -
1308 - if ( $maybe_absolute_link == get_option( 'siteurl' ) ) {
1309 - $maybe_absolute_link = '/';
1310 - }
1311 -
1312 - $maybe_absolute_link = '/' . trim( wp_make_link_relative( $maybe_absolute_link ), '/' );
1313 -
1314 - return $maybe_absolute_link;
1315 - }
1316 -
1317 - /**
1318 - * Get Absolute URL (check for languages)
1319 - *
1320 - * @param $maybe_relative_link
1321 - *
1322 - * @return string
1323 - */
1324 - function wpbc_make_link_absolute( $maybe_relative_link ){
1325 -
1326 - if ( ( $maybe_relative_link != home_url() ) && ( strpos( $maybe_relative_link, 'http' ) !== 0 ) ) {
1327 -
1328 - $maybe_relative_link = wpbc_lang( $maybe_relative_link ); //FixIn: 8.4.5.1
1329 -
1330 - $maybe_relative_link = home_url() . '/' . trim( wp_make_link_relative( $maybe_relative_link ), '/' ); //FixIn: 7.0.1.20
1331 - }
1332 -
1333 - return esc_js( $maybe_relative_link );
1334 - }
1335 -
1336 -
1337 - /**
1338 - * Redirect browser to a specific page
1339 - *
1340 - * @param string $url - URL of page to redirect
1341 - */
1342 - function wpbc_redirect( $url ) {
1343 -
1344 - $url = wpbc_make_link_absolute( $url );
1345 -
1346 - $url = html_entity_decode( esc_url( $url ) );
1347 -
1348 - echo '<script type="text/javascript">';
1349 - echo 'window.location.href="'.$url.'";';
1350 - echo '</script>';
1351 - echo '<noscript>';
1352 - echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
1353 - echo '</noscript>';
1354 - }
1355 -
1356 - // </editor-fold>
1357 -
1358 -
1359 - // <editor-fold defaultstate="collapsed" desc=" == Get Admin Menu URLs == " >
1360 -
1361 - /**
1362 - * Check if we edit or create a new page in WordPress ?
1363 - * @return bool
1364 - */
1365 - function wpbc_is_on_edit_page() {
1366 -
1367 - //FixIn: 9.9.0.39
1368 -
1369 - if ( ( ! empty( $GLOBALS['pagenow'] ) ) && ( is_admin() ) ) {
1370 - if (
1371 - ( 'post.php' === $GLOBALS['pagenow'] ) // Edit - Post / Page
1372 - || ( 'post-new.php' === $GLOBALS['pagenow'] ) // Add New - Post / Page
1373 - || ( ( 'admin-ajax.php' === $GLOBALS['pagenow'] ) && ( ! empty( $_REQUEST['action'] ) ) && ( 'elementor_ajax' === $_REQUEST['action'] ) ) // Elementor Edit page - Ajax
1374 - ) {
1375 - return true;
1376 - }
1377 - }
1378 -
1379 - return false;
1380 - }
1381 -
1382 -
1383 - /**
1384 - * Get URL to specific Admin Menu page
1385 - *
1386 - * @param string $menu_type - { booking | add | resources | settings }
1387 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1388 - * @param boolean $is_old - { default: true }
1389 - * @return string - URL to menu
1390 - */
1391 - function wpbc_get_menu_url( $menu_type, $is_absolute_url = true, $is_old = true) {
1392 -
1393 - $is_old = false;
1394 -
1395 - switch ( $menu_type) {
1396 -
1397 - case 'booking': // Bookings
1398 - case 'bookings':
1399 - case 'booking-listing':
1400 - case 'bookings-listing':
1401 - case 'listing':
1402 - case 'overview':
1403 - case 'calendar-overview':
1404 - case 'timeline':
1405 - $link = 'wpbc';
1406 - break;
1407 -
1408 - case 'add': // Add New Booking
1409 - case 'add-bookings':
1410 - case 'add-booking':
1411 - case 'new':
1412 - case 'new-bookings':
1413 - case 'new-booking':
1414 - $link = 'wpbc-new';
1415 - break;
1416 -
1417 - case 'availability':
1418 - $link = 'wpbc-availability';
1419 - break;
1420 -
1421 - case 'price':
1422 - $link = 'wpbc-prices';
1423 - break;
1424 -
1425 - case 'resources': // Resources
1426 - case 'booking-resources':
1427 - $link = 'wpbc-resources';
1428 - break;
1429 -
1430 - case 'settings': // Settings
1431 - case 'options':
1432 - $link = 'wpbc-settings';
1433 - break;
1434 -
1435 - default: // Bookings
1436 - $link = 'wpbc';
1437 - break;
1438 - }
1439 -
1440 - if ( $is_absolute_url ) {
1441 - $link = admin_url( 'admin.php' ) . '?page=' . $link ;
1442 - }
1443 -
1444 - return $link;
1445 - }
1446 -
1447 - // -----------------------------------------------------------------------------------------------------------------
1448 -
1449 - /**
1450 - * Get URL of Booking Listing or Calendar Overview page
1451 - *
1452 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1453 - * @param boolean $is_old - { default: true }
1454 - * @return string - URL to menu
1455 - */
1456 - function wpbc_get_bookings_url( $is_absolute_url = true, $is_old = true ) {
1457 - return wpbc_get_menu_url( 'booking', $is_absolute_url, $is_old );
1458 - }
1459 -
1460 - /**
1461 - * Get URL of Booking > Availability page
1462 - *
1463 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1464 - * @param boolean $is_old - { default: true }
1465 - * @return string - URL to menu
1466 - */
1467 - function wpbc_get_availability_url( $is_absolute_url = true, $is_old = true ) {
1468 - return wpbc_get_menu_url( 'availability', $is_absolute_url, $is_old );
1469 - }
1470 -
1471 - /**
1472 - * Get URL of Booking > Availability page
1473 - *
1474 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1475 - * @param boolean $is_old - { default: true }
1476 - * @return string - URL to menu
1477 - */
1478 - function wpbc_get_price_url( $is_absolute_url = true, $is_old = true ) {
1479 - return wpbc_get_menu_url( 'price', $is_absolute_url, $is_old );
1480 - }
1481 -
1482 - /**
1483 - * Get URL of Booking > Add booking page
1484 - *
1485 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1486 - * @param boolean $is_old - { default: true }
1487 - * @return string - URL to menu
1488 - */
1489 - function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) {
1490 - return wpbc_get_menu_url( 'add', $is_absolute_url, $is_old );
1491 - }
1492 -
1493 - /**
1494 - * Get URL of Booking > Resources page
1495 - *
1496 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1497 - * @param boolean $is_old - { default: true }
1498 - * @return string - URL to menu
1499 - */
1500 - function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) {
1501 - return wpbc_get_menu_url( 'resources', $is_absolute_url, $is_old );
1502 - }
1503 -
1504 - /**
1505 - * Get URL of Booking > Settings page
1506 - *
1507 - * @param boolean $is_absolute_url - Absolute or relative url { default: true }
1508 - * @param boolean $is_old - { default: true }
1509 - * @return string - URL to menu
1510 - */
1511 - function wpbc_get_settings_url( $is_absolute_url = true, $is_old = true ) {
1512 - return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old );
1513 - }
1514 -
1515 - // -----------------------------------------------------------------------------------------------------------------
1516 -
1517 - /**
1518 - * Check if this Booking Listing or Calendar Overview page
1519 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1520 - * @return boolean true | false
1521 - */
1522 - function wpbc_is_bookings_page( $server_param = 'REQUEST_URI' ) {
1523 - // Old
1524 - if ( ( is_admin() ) &&
1525 - ( strpos($_SERVER[ $server_param ],'wpdev-booking.phpwpdev-booking') !== false ) &&
1526 - ( strpos($_SERVER[ $server_param ],'wpdev-booking.phpwpdev-booking-reservation') === false )
1527 - ) {
1528 - return true;
1529 - }
1530 - // New
1531 - if ( ( is_admin() ) &&
1532 - ( strpos($_SERVER[ $server_param ],'page=wpbc') !== false ) &&
1533 - ( strpos($_SERVER[ $server_param ],'page=wpbc-') === false )
1534 - ) {
1535 - return true;
1536 - }
1537 - return false;
1538 - }
1539 -
1540 - /**
1541 - * Check if this Booking > Add booking page
1542 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1543 - * @return boolean true | false
1544 - */
1545 - function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) {
1546 - // Old
1547 - if ( ( is_admin() ) &&
1548 - ( strpos($_SERVER[ $server_param ],'wpdev-booking.phpwpdev-booking-reservation') !== false )
1549 - ) {
1550 - return true;
1551 - }
1552 - // New
1553 - if ( ( is_admin() ) &&
1554 - ( strpos($_SERVER[ $server_param ],'page=wpbc-new') !== false )
1555 - ) {
1556 - return true;
1557 - }
1558 - return false;
1559 - }
1560 -
1561 - /**
1562 - * Check if this WP Booking Calendar > Settings > Booking Form page
1563 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1564 - * @return boolean true | false
1565 - */
1566 - function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) {
1567 -
1568 - if ( ( is_admin() ) &&
1569 - ( strpos($_SERVER[ $server_param ],'page=wpbc-settings') !== false ) &&
1570 - (
1571 - ( strpos($_SERVER[ $server_param ],'&tab=form') !== false )
1572 - || ( ( class_exists( 'wpdev_bk_multiuser' ) ) && ( ! empty( $_REQUEST['tab'] ) ) && ( 'form' === $_REQUEST['tab'] ) ) // Regular user overwrite settings
1573 - )
1574 - ) {
1575 - return true;
1576 - }
1577 - return false;
1578 - }
1579 -
1580 - /**
1581 - * Check if this Booking > Availability page
1582 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1583 - * @return boolean true | false
1584 - */
1585 - function wpbc_is_availability_page( $server_param = 'REQUEST_URI' ) {
1586 -
1587 - // New
1588 - if ( ( is_admin() ) &&
1589 - ( strpos($_SERVER[ $server_param ],'page=wpbc-availability') !== false )
1590 - ) {
1591 - return true;
1592 - }
1593 - return false;
1594 - }
1595 -
1596 -
1597 - /**
1598 - * Check if this Booking > Customize page
1599 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1600 - * @return boolean true | false
1601 - */
1602 - function wpbc_is_customize_plugin_page( $server_param = 'REQUEST_URI' ) { //FixIn: 9.8.0.1
1603 -
1604 - // New
1605 - if ( ( is_admin() ) &&
1606 - ( strpos($_SERVER[ $server_param ],'page=wpbc-customize_plugin') !== false )
1607 - ) {
1608 - return true;
1609 - }
1610 - return false;
1611 - }
1612 -
1613 -
1614 - // -----------------------------------------------------------------------------------------------------------------
1615 -
1616 - /**
1617 - * Check if this Booking > Resources page
1618 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1619 - * @return boolean true | false
1620 - */
1621 - function wpbc_is_resources_page( $server_param = 'REQUEST_URI' ) {
1622 -
1623 - // Old
1624 - if ( ( is_admin() ) &&
1625 - ( strpos($_SERVER[ $server_param ],'wpdev-booking.phpwpdev-booking-resources') !== false )
1626 - ) {
1627 - return true;
1628 - }
1629 - // New
1630 - if ( ( is_admin() ) &&
1631 - ( strpos($_SERVER[ $server_param ],'page=wpbc-resources') !== false )
1632 - ) {
1633 - return true;
1634 - }
1635 - return false;
1636 - }
1637 -
1638 - /**
1639 - * Check if this Booking > Settings page
1640 - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
1641 - * @return boolean true | false
1642 - */
1643 - function wpbc_is_settings_page( $server_param = 'REQUEST_URI' ) {
1644 -
1645 - // Old
1646 - if ( ( is_admin() ) &&
1647 - ( strpos($_SERVER[ $server_param ],'wpdev-booking.phpwpdev-booking-option') !== false )
1648 - ) {
1649 - return true;
1650 - }
1651 - // New
1652 - if ( ( is_admin() ) &&
1653 - ( strpos($_SERVER[ $server_param ],'page=wpbc-settings') !== false )
1654 - ) {
1655 - return true;
1656 - }
1657 - return false;
1658 - }
1659 -
1660 -
1661 - // -----------------------------------------------------------------------------------------------------------------
1662 -
1663 -
1664 - /**
1665 - * Transform the REQESTS parameters (GET and POST) into URL
1666 - *
1667 - * @param $page_param
1668 - * @param array $exclude_params
1669 - * @param $only_these_parameters
1670 - * @return
1671 - */
1672 - function wpbc_get_params_in_url( $page_param , $exclude_params = array(), $only_these_parameters = false, $is_escape_url = true, $only_get = false ){ //FixIn: 8.0.1.101 //Fix: $is_escape_url = false
1673 -
1674 - $exclude_params[] = 'page';
1675 - $exclude_params[] = 'post_type';
1676 -
1677 - if ( isset( $_GET['page'] ) )
1678 - $page_param = $_GET['page'];
1679 -
1680 - $get_paramaters = array( 'page' => $page_param );
1681 -
1682 - if ( $only_get )
1683 - $check_params = $_GET;
1684 - else
1685 - $check_params = $_REQUEST;
1686 - //debuge($check_params);
1687 - foreach ( $check_params as $prm_key => $prm_value ) {
1688 -
1689 - // Skip parameters arrays, like $_GET['rvaluation_to'] = Array ( [0] => 6, [1] => 14, [2] => 14 )
1690 - if (
1691 - ( is_string( $prm_value ) )
1692 - || ( is_numeric( $prm_value ) )
1693 - ) {
1694 -
1695 - if ( strlen( $prm_value ) > 1000 ) { // Check about TOOO long parameters, if it exist then reset it.
1696 - $prm_value = '';
1697 - }
1698 -
1699 - if ( ! in_array( $prm_key, $exclude_params ) )
1700 - if ( ( $only_these_parameters === false ) || ( in_array( $prm_key, $only_these_parameters ) ) )
1701 - $get_paramaters[ $prm_key ] = $prm_value;
1702 - }
1703 - }
1704 - //debuge($exclude_params);
1705 - $url = admin_url( add_query_arg( $get_paramaters , 'admin.php' ) );
1706 -
1707 - if ( $is_escape_url )
1708 - $url = esc_url_raw( $url ); //FixIn: 8.1.1.7
1709 - // $url = esc_url( $url );
1710 -
1711 - return $url;
1712 -
1713 - /* // Old variant:
1714 - if ( isset( $_GET['page'] ) ) $page_param = $_GET['page'];
1715 -
1716 - $url_start = 'admin.php?page=' . $page_param . '&';
1717 - $exclude_params[] = 'page';
1718 - foreach ( $_REQUEST as $prm_key => $prm_value ) {
1719 -
1720 - if ( !in_array( $prm_key, $exclude_params ) )
1721 - if ( ($only_these_parameters === false) || ( in_array( $prm_key, $only_these_parameters ) ) )
1722 -
1723 - $url_start .= $prm_key . '=' . $prm_value . '&';
1724 -
1725 - }
1726 - $url_start = substr( $url_start, 0, -1 );
1727 -
1728 - return $url_start;
1729 - */
1730 - }
1731 -
1732 -
1733 - // </editor-fold>
1734 -
1735 -
1736 511 // <editor-fold defaultstate="collapsed" desc=" == Can I Load JavaScript Files == " >
1737 512
1738 513 function wpbc_can_i_load_on__edit_new_post_page() {
1739 514
@@ -1742,10 +517,12 @@
1742 517 }
1743 518
1744 519
1745 520 $pages_where_load = array( 'post-new.php', 'page-new.php', 'post.php', 'page.php', 'widgets.php', 'customize.php' );
1746 -
1747 - if ( in_array( basename( $_SERVER['PHP_SELF'] ), $pages_where_load ) ) {
521 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
522 + if ( ( in_array( basename( $_SERVER['PHP_SELF'] ), $pages_where_load ) )
523 + || ( wpbc_is_setup_wizard_page() )
524 + ) {
1748 525 return true;
1749 526 }
1750 527
1751 528 return false;
@@ -1754,10 +531,10 @@
1754 531
1755 532 function wpbc_can_i_load_on__searchable_resources_page() {
1756 533
1757 534 if (
1758 - ( isset( $_REQUEST['page'] ) ) && ( $_REQUEST['page'] == 'wpbc-resources' )
1759 - && ( isset( $_REQUEST['tab'] ) ) && ( $_REQUEST['tab'] == 'searchable_resources' )
535 + ( isset( $_REQUEST['page'] ) ) && ( $_REQUEST['page'] === 'wpbc-resources' ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
536 + && ( isset( $_REQUEST['tab'] ) ) && ( $_REQUEST['tab'] === 'searchable_resources' ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1760 537 ) {
1761 538 return true;
1762 539 }
1763 540
@@ -1767,9 +544,22 @@
1767 544
1768 545 function wpbc_can_i_load_on__resources_page() {
1769 546
1770 547 if (
1771 - ( isset( $_REQUEST['page'] ) ) && ( $_REQUEST['page'] == 'wpbc-resources' )
548 + ( isset( $_REQUEST['page'] ) )
549 + && (
550 + ( $_REQUEST['page'] === 'wpbc-resources' ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
551 + || (
552 + ( $_REQUEST['page'] === 'wpbc-booking-resources' ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
553 + && function_exists( 'wpbc_is_11_6_features_enabled' )
554 + && wpbc_is_11_6_features_enabled()
555 + )
556 + || (
557 + ( $_REQUEST['page'] === 'wpbc-catalog-booking-resources' ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
558 + && function_exists( 'wpbc_is_11_6_features_enabled' )
559 + && wpbc_is_11_6_features_enabled()
560 + )
561 + )
1772 562 ) {
1773 563 return true;
1774 564 }
1775 565
@@ -1789,8 +579,11 @@
1789 579 || (
1790 580 wpbc_can_i_load_on__resources_page()
1791 581 && ( ! wpbc_can_i_load_on__searchable_resources_page() )
1792 582 )
583 + || wpbc_is_setup_wizard_page()
584 + || wpbc_is_builder_booking_form_page()
585 + // || wpbc_is_bookings_page() // FixIn: 10.6.6.2.
1793 586 ){
1794 587 return true;
1795 588 } else {
1796 589 return false;
@@ -1803,9 +596,15 @@
1803 596 * @return bool
1804 597 */
1805 598 function wpbc_can_i_load_on_this_page__modal_search_options() {
1806 599
1807 - if ( wpbc_can_i_load_on__searchable_resources_page() ){
600 + if (
601 + wpbc_can_i_load_on__searchable_resources_page()
602 + || (
603 + function_exists( 'wpbc_catalog_searchable_resources_is_page' )
604 + && wpbc_catalog_searchable_resources_is_page()
605 + )
606 + ) {
1808 607 return true;
1809 608 } else {
1810 609 return false;
1811 610 }
@@ -1813,324 +612,8 @@
1813 612
1814 613 // </editor-fold>
1815 614
1816 615
1817 - // <editor-fold defaultstate="collapsed" desc=" == Admin Top Bar == " >
1818 -
1819 - function wpbc_add__booking_menu__in__admin_top_bar(){
1820 - global $wp_admin_bar;
1821 -
1822 - $current_user = wpbc_get_current_user();
1823 -
1824 - $curr_user_role = get_bk_option( 'booking_user_role_booking' );
1825 - $level = 10;
1826 - if ($curr_user_role == 'administrator') $level = 10;
1827 - else if ($curr_user_role == 'editor') $level = 7;
1828 - else if ($curr_user_role == 'author') $level = 2;
1829 - else if ($curr_user_role == 'contributor') $level = 1;
1830 - else if ($curr_user_role == 'subscriber') $level = 0;
1831 -
1832 - $is_super_admin = apply_bk_filter('multiuser_is_user_can_be_here', false, 'only_super_admin');
1833 - if ( ( ($current_user->user_level < $level) && (! $is_super_admin) ) || !is_admin_bar_showing() ) return;
1834 -
1835 -
1836 - $update_count = wpbc_db_get_number_new_bookings();
1837 -
1838 - $title = 'Booking Calendar';//__('Booking Calendar' ,'booking'); //FixIn: 9.1.3.3
1839 - $update_title = ''// '<img src="'.WPBC_PLUGIN_URL .'/assets/img/icon-16x16.png" style="height: 16px;vertical-align: sub;" />&nbsp;'
1840 - . $title;
1841 -
1842 -
1843 -
1844 - $is_user_activated = apply_bk_filter('multiuser_is_current_user_active', true ); //FixIn: 6.0.1.17
1845 - if ( ( $update_count > 0) && ( $is_user_activated ) ) {
1846 - $update_count_title = "&nbsp;<span class='booking-count bk-update-count' style='background: #f0f0f1;color: #2c3338;display: inline;padding: 2px 5px;font-weight: 600;border-radius: 10px;'>"
1847 - . number_format_i18n($update_count)
1848 - . "</span>" ; //id='booking-count'
1849 - $update_title .= $update_count_title;
1850 - }
1851 -
1852 - $link_bookings = wpbc_get_bookings_url();
1853 - $link_res = wpbc_get_resources_url();
1854 - $link_settings = wpbc_get_settings_url();
1855 -
1856 - //FixIn: 9.8.15.9
1857 - $wp_admin_bar->add_menu(
1858 - array(
1859 - 'id' => 'bar_wpbc',
1860 - 'title' => $update_title ,
1861 - 'href' => wpbc_get_bookings_url()
1862 - )
1863 - );
1864 -
1865 - $wp_admin_bar->add_menu(
1866 - array(
1867 - 'id' => 'bar_wpbc_bookings',
1868 - 'title' => __( 'Bookings', 'booking' ),
1869 - 'href' => wpbc_get_bookings_url(),
1870 - 'parent' => 'bar_wpbc',
1871 - )
1872 - );
1873 - $wp_admin_bar->add_menu(
1874 - array(
1875 - 'id' => 'bar_wpbc_booking_listing',
1876 - 'title' => __( 'Booking Listing', 'booking' ),
1877 - 'href' => wpbc_get_bookings_url() . '&view_mode=vm_listing',
1878 - 'parent' => 'bar_wpbc_bookings',
1879 - )
1880 - );
1881 - $wp_admin_bar->add_menu(
1882 - array(
1883 - 'id' => 'bar_wpbc_calendar_overview',
1884 - 'title' => __( 'Calendar Overview', 'booking' ),
1885 - 'href' => wpbc_get_bookings_url() . '&view_mode=vm_calendar',
1886 - 'parent' => 'bar_wpbc_bookings',
1887 - )
1888 - );
1889 -
1890 -
1891 - $curr_user_role_settings = get_bk_option( 'booking_user_role_settings' );
1892 - $level = 10;
1893 - if ($curr_user_role_settings == 'administrator') $level = 10;
1894 - else if ($curr_user_role_settings == 'editor') $level = 7;
1895 - else if ($curr_user_role_settings == 'author') $level = 2;
1896 - else if ($curr_user_role_settings == 'contributor') $level = 1;
1897 - else if ($curr_user_role_settings == 'subscriber') $level = 0;
1898 -
1899 - if ( ( ($current_user->user_level < $level) && (! $is_super_admin) ) || !is_admin_bar_showing() ) return;
1900 -
1901 - // Booking > Add booking page
1902 - $wp_admin_bar->add_menu(
1903 - array(
1904 - 'id' => 'bar_wpbc_new',
1905 - 'title' => __( 'Add booking', 'booking' ),
1906 - 'href' => wpbc_get_new_booking_url(),
1907 - 'parent' => 'bar_wpbc',
1908 - )
1909 - );
1910 -
1911 - // Booking > Availability page
1912 - $wp_admin_bar->add_menu(
1913 - array(
1914 - 'id' => 'bar_wpbc_availability',
1915 - 'title' => __( 'Availability', 'booking' ),
1916 - 'href' => wpbc_get_availability_url(),
1917 - 'parent' => 'bar_wpbc',
1918 - )
1919 - );
1920 - $wp_admin_bar->add_menu(
1921 - array(
1922 - 'id' => 'bar_wpbc_days_availability',
1923 - 'title' => __( 'Days Availability', 'booking' ),
1924 - 'href' => wpbc_get_availability_url() ,
1925 - 'parent' => 'bar_wpbc_availability'
1926 - )
1927 - );
1928 - if ( class_exists( 'wpdev_bk_biz_m' ) ){
1929 - $wp_admin_bar->add_menu(
1930 - array(
1931 - 'id' => 'bar_wpbc_seasons_availability',
1932 - 'title' => __( 'Season Availability', 'booking' ),
1933 - 'href' => wpbc_get_availability_url() . '&tab=season_availability',
1934 - 'parent' => 'bar_wpbc_availability'
1935 - )
1936 - );
1937 -
1938 - $wp_admin_bar->add_menu(
1939 - array(
1940 - 'id' => 'bar_wpbc_seasons_filters',
1941 - 'title' => __( 'Seasons', 'booking' ),
1942 - 'href' => wpbc_get_availability_url() . '&tab=filter',
1943 - 'parent' => 'bar_wpbc_availability'
1944 - )
1945 - );
1946 - }
1947 - if ( wpbc_is_mu_user_can_be_here( 'only_super_admin' ) )
1948 - $wp_admin_bar->add_menu(
1949 - array(
1950 - 'id' => 'bar_wpbc_general_availability',
1951 - 'title' => __( 'General Availability', 'booking' ),
1952 - 'href' => wpbc_get_settings_url() . '&scroll_to_section=wpbc_general_settings_availability_tab',
1953 - 'parent' => 'bar_wpbc_availability'
1954 - )
1955 - );
1956 -
1957 - // Booking > Prices page
1958 - if ( class_exists( 'wpdev_bk_biz_m' ) ){
1959 -
1960 - $wp_admin_bar->add_menu(
1961 - array(
1962 - 'id' => 'bar_wpbc_prices',
1963 - 'title' => __( 'Prices', 'booking' ),
1964 - 'href' => wpbc_get_price_url(),
1965 - 'parent' => 'bar_wpbc',
1966 - )
1967 - );
1968 - $wp_admin_bar->add_menu(
1969 - array(
1970 - 'id' => 'bar_wpbc_daily_costs',
1971 - 'title' => __('Daily Costs','booking'),
1972 - 'href' => wpbc_get_price_url() . '&tab=cost',
1973 - 'parent' => 'bar_wpbc_prices',
1974 - )
1975 - );
1976 - $wp_admin_bar->add_menu(
1977 - array(
1978 - 'id' => 'bar_wpbc_cost_advanced',
1979 - 'title' => __('Form Options Costs','booking'),
1980 - 'href' => wpbc_get_price_url() . '&tab=cost_advanced',
1981 - 'parent' => 'bar_wpbc_prices',
1982 - )
1983 - );
1984 - if ( class_exists( 'wpdev_bk_biz_l' ) ){
1985 - $wp_admin_bar->add_menu(
1986 - array(
1987 - 'id' => 'bar_wpbc_coupons',
1988 - 'title' => __('Discount Coupons','booking'),
1989 - 'href' => wpbc_get_price_url() . '&tab=coupons',
1990 - 'parent' => 'bar_wpbc_prices',
1991 - )
1992 - );
1993 - }
1994 - $wp_admin_bar->add_menu(
1995 - array(
1996 - 'id' => 'bar_wpbc_seasons_costs',
1997 - 'title' => __( 'Seasons', 'booking' ),
1998 - 'href' => wpbc_get_price_url() . '&tab=filter',
1999 - 'parent' => 'bar_wpbc_prices'
2000 - )
2001 - );
2002 - $wp_admin_bar->add_menu(
2003 - array(
2004 - 'id' => 'bar_wpbc_costs_payment_gateways',
2005 - 'title' => __( 'Payment Setup', 'booking' ),
2006 - 'href' => wpbc_get_settings_url() . '&tab=payment',
2007 - 'parent' => 'bar_wpbc_prices'
2008 - )
2009 - );
2010 -
2011 - }
2012 -
2013 - //Booking > Resources page
2014 - $wp_admin_bar->add_menu(
2015 - array(
2016 - 'id' => 'bar_wpbc_resources',
2017 - 'title' => ( ( class_exists( 'wpdev_bk_personal' ) ) ? __( 'Resources', 'booking' ) : __( 'Resource', 'booking' ) ),
2018 - 'href' => $link_res,
2019 - 'parent' => 'bar_wpbc',
2020 - )
2021 - );
2022 - $wp_admin_bar->add_menu(
2023 - array(
2024 - 'id' => 'bar_wpbc_resources_general',
2025 - 'title' => ( ( class_exists( 'wpdev_bk_personal' ) ) ? __( 'Resources', 'booking' ) : __( 'Resource', 'booking' ) ),
2026 - 'href' => $link_res,
2027 - 'parent' => 'bar_wpbc_resources',
2028 - )
2029 - );
2030 -
2031 - if ( class_exists( 'wpdev_bk_biz_l' ) )
2032 - $wp_admin_bar->add_menu(
2033 - array(
2034 - 'id' => 'bar_wpbc_resources_searchable',
2035 - 'title' => __( 'Search Resources Setup', 'booking' ),//__( 'Searchable Resources', 'booking' ),//__( 'Search Availability', 'booking' ),
2036 - 'href' => $link_res . '&tab=searchable_resources',
2037 - 'parent' => 'bar_wpbc_resources'
2038 - )
2039 - );
2040 -
2041 -// if ($is_super_admin)
2042 -// if ( class_exists( 'wpdev_bk_biz_l' ) )
2043 -// $wp_admin_bar->add_menu(
2044 -// array(
2045 -// 'id' => 'bar_wpbc_resources_search',
2046 -// 'title' => __( 'Search Form / Results', 'booking' ),
2047 -// 'href' => $link_settings . '&tab=search',
2048 -// 'parent' => 'bar_wpbc_resources'
2049 -// )
2050 -// );
2051 -
2052 -
2053 - //Booking > Settings General page
2054 -
2055 - $wp_admin_bar->add_menu(
2056 - array(
2057 - 'id' => 'bar_wpbc_settings',
2058 - 'title' => __( 'Settings', 'booking' ),
2059 - 'href' => wpbc_get_settings_url(),
2060 - 'parent' => 'bar_wpbc',
2061 - )
2062 - );
2063 -
2064 - if ($is_super_admin)
2065 - $wp_admin_bar->add_menu(
2066 - array(
2067 - 'id' => 'bar_wpbc_settings_general',
2068 - 'title' => __( 'General', 'booking' ),
2069 - 'href' => $link_settings,
2070 - 'parent' => 'bar_wpbc_settings'
2071 - )
2072 - );
2073 - $wp_admin_bar->add_menu(
2074 - array(
2075 - 'id' => 'bar_wpbc_settings_form',
2076 - 'title' => __( 'Booking Form', 'booking' ),
2077 - 'href' => $link_settings . '&tab=form',
2078 - 'parent' => 'bar_wpbc_settings'
2079 - )
2080 - );
2081 - $wp_admin_bar->add_menu(
2082 - array(
2083 - 'id' => 'bar_wpbc_settings_email',
2084 - 'title' => __( 'Emails', 'booking' ),
2085 - 'href' => $link_settings . '&tab=email',
2086 - 'parent' => 'bar_wpbc_settings'
2087 - )
2088 - );
2089 - $wp_admin_bar->add_menu(
2090 - array(
2091 - 'id' => 'bar_wpbc_settings_sync',
2092 - 'title' => __( 'Sync', 'booking' ), //FixIn: 8.0
2093 - 'href' => $link_settings . '&tab=sync',
2094 - 'parent' => 'bar_wpbc_settings'
2095 - )
2096 - );
2097 - if ( class_exists( 'wpdev_bk_biz_s' ) )
2098 - $wp_admin_bar->add_menu(
2099 - array(
2100 - 'id' => 'bar_wpbc_settings_payment',
2101 - 'title' => __( 'Payment Setup', 'booking' ),
2102 - 'href' => $link_settings . '&tab=payment',
2103 - 'parent' => 'bar_wpbc_settings'
2104 - )
2105 - );
2106 -
2107 - if ( ( class_exists( 'wpdev_bk_biz_l' ) ) && ( wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) )
2108 - $wp_admin_bar->add_menu(
2109 - array(
2110 - 'id' => 'bar_wpbc_settings_search',
2111 - 'title' => __( 'Search Form / Results', 'booking' ),
2112 - 'href' => $link_settings . '&tab=search',
2113 - 'parent' => 'bar_wpbc_settings'
2114 - )
2115 - );
2116 - if ( class_exists( 'wpdev_bk_multiuser' ) )
2117 - if ($is_super_admin)
2118 - $wp_admin_bar->add_menu(
2119 - array(
2120 - 'id' => 'bar_wpbc_settings_users',
2121 - 'title' => __( 'Users', 'booking' ),
2122 - 'href' => $link_settings . '&tab=users',
2123 - 'parent' => 'bar_wpbc_settings'
2124 - )
2125 - );
2126 - }
2127 - add_action( 'admin_bar_menu', 'wpbc_add__booking_menu__in__admin_top_bar', 70 ); // Add - TOP Bar - in admin menu
2128 -
2129 -
2130 - // </editor-fold>
2131 -
2132 -
2133 616 // <editor-fold defaultstate="collapsed" desc=" == Footer == " >
2134 617
2135 618 function wpbc_show_booking_footer(){
2136 619
@@ -2141,18 +624,12 @@
2141 624
2142 625
2143 626 if ( ( 'Off' !== $wpdev_copyright_adminpanel ) && ( ! wpbc_is_this_demo() ) ) {
2144 627
2145 - /*
2146 - $message .= '<a target="_blank" href="https://wpbookingcalendar.com/">Booking Calendar</a> ' . __('version' ,'booking') . ' ' . WP_BK_VERSION_NUM ;
2147 628
2148 - $message .= ' | '. sprintf(__('Add your %s on %swordpress.org%s, if you enjoyed by this plugin.' ,'booking'),
2149 - '<a target="_blank" href="http://goo.gl/tcrrpK" >&#9733;&#9733;&#9733;&#9733;&#9733;</a>',
2150 - '<a target="_blank" href="http://goo.gl/tcrrpK" >',
2151 - '</a>' );
2152 - */
2153 - $message .= sprintf( __( 'If you like %s please leave us a %s rating. A huge thank you in advance!', 'booking' )
2154 - , '<strong>Booking Calendar</strong> ' . WP_BK_VERSION_NUM
629 + /* translators: 1: ... */
630 + $message .= sprintf( __( 'If you like %1$s please leave us a %2$s rating. A huge thank you in advance!', 'booking' )
631 + , '<strong>Booking Calendar</strong> ' . esc_attr( WP_BK_VERSION_NUM )
2155 632 , '<a href="https://wordpress.org/support/plugin/booking/reviews/#new-post" target="_blank" title="' . esc_attr__( 'Thanks :)', 'booking' ) . '">'
2156 633 . '&#9733;&#9733;&#9733;&#9733;&#9733;'
2157 634 . '</a>'
2158 635 );
@@ -2158,19 +635,22 @@
2158 635 );
2159 636 }
2160 637
2161 638
2162 - if ( ! empty( $message ) ) {
639 + if ( ! empty( $message ) ) {
2163 640
2164 - echo '<div id="wpbc-footer" style="position:absolute;bottom:40px;text-align:left;width:95%;font-size:0.9em;text-shadow:0 1px 0 #fff;margin:0;color:#888;">' . $message . '</div>';
641 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
642 + echo '<div id="wpbc-footer" style="position:absolute;bottom:40px;text-align:left;width:95%;font-size:0.9em;text-shadow:0 1px 0 #fff;margin:0;color:#888;">' . $message . '</div>';
2165 643
2166 - ?><script type="text/javascript">
2167 - jQuery( document ).ready( function (){
2168 - jQuery( '#wpfooter' ).append( jQuery( '#wpbc-footer' ) );
2169 - } );
2170 - </script><?php
2171 - }
644 + ?>
645 + <script type="text/javascript">
646 + jQuery(document).ready(function () {
647 + jQuery('#wpfooter').append(jQuery('#wpbc-footer'));
648 + });
649 + </script>
650 + <?php
2172 651 }
652 + }
2173 653
2174 654 // </editor-fold>
2175 655
2176 656
@@ -2194,12 +674,13 @@
2194 674 $pages_number = ceil( $summ_number_of_items / $num_items_per_page );
2195 675 if ( $pages_number < 2 )
2196 676 return;
2197 677
2198 - //Fix: 5.1.4 - Just in case we are having tooo much resources, then we need to show all resources - and its empty string
2199 - if ( ( isset($_REQUEST['wh_booking_type'] ) ) && ( strlen($_REQUEST['wh_booking_type']) > 1000 ) ) {
2200 - $_REQUEST['wh_booking_type'] = '';
2201 - }
678 + //Fix: 5.1.4 - Just in case we are having tooo much resources, then we need to show all resources - and its empty string
679 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
680 + if ( ( isset( $_REQUEST['wh_booking_type'] ) ) && ( strlen( wp_unslash( $_REQUEST['wh_booking_type'] ) ) > 1000 ) ) {
681 + $_REQUEST['wh_booking_type'] = '';
682 + }
2202 683
2203 684 // First parameter will overwriten by $_GET['page'] parameter
2204 685 $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), array('page_num'), $only_these_parameters );
2205 686
@@ -2211,14 +692,26 @@
2211 692 <div class="col-sm-12 text-center control-group0">
2212 693 <nav class="btn-toolbar">
2213 694 <div class="btn-group wpbc-no-margin" style="float:none;">
2214 695
2215 - <?php if ( $pages_number > 1 ) { ?>
2216 - <a class="button button-secondary <?php echo ( $active_page_num == 1 ) ? ' disabled' : ''; ?>"
2217 - href="<?php echo $bk_admin_url; ?>&page_num=<?php if ($active_page_num == 1) { echo $active_page_num; } else { echo ($active_page_num-1); } echo $url_sufix; ?>">
2218 - <?php _e('Prev', 'booking'); ?>
696 + <?php
697 + if ( $pages_number > 1 ) { ?>
698 + <a class="button button-secondary <?php
699 + echo ( $active_page_num == 1 ) ? ' disabled' : ''; ?>"
700 + href="<?php
701 + echo esc_url( $bk_admin_url ); ?>&page_num=<?php
702 + if ( $active_page_num == 1 ) {
703 + echo esc_attr( $active_page_num );
704 + } else {
705 + echo esc_attr( $active_page_num - 1 );
706 + }
707 + echo esc_attr( $url_sufix );
708 + ?>">
709 + <?php
710 + esc_html_e( 'Prev', 'booking' ); ?>
2219 711 </a>
2220 - <?php }
712 + <?php
713 + }
2221 714
2222 715 /** Number visible pages (links) that linked to active page, other pages skipped by "..." */
2223 716 $num_closed_steps = 3;
2224 717
@@ -2230,10 +723,12 @@
2230 723 && ( ( $pages_number - $pg_num + 1 ) > $num_closed_steps )
2231 724 && ( abs( $active_page_num - $pg_num ) > $num_closed_steps )
2232 725 ) ) {
2233 726 ?> <a class="button button-secondary <?php if ($pg_num == $active_page_num ) echo ' active'; ?>"
2234 - href="<?php echo $bk_admin_url; ?>&page_num=<?php echo $pg_num; echo $url_sufix; ?>">
2235 - <?php echo $pg_num; ?>
727 + href="<?php echo esc_url( $bk_admin_url ); ?>&page_num=<?php echo esc_attr( $pg_num );
728 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
729 + echo $url_sufix; ?>">
730 + <?php echo wp_kses_post( $pg_num ); ?>
2236 731 </a><?php
2237 732
2238 733 if ( ( $pages_number > ( $num_closed_steps * 4) )
2239 734 && ( ($pg_num+1) > $num_closed_steps )
@@ -2245,13 +740,25 @@
2245 740 }
2246 741 }
2247 742
2248 743 if ( $pages_number > 1 ) { ?>
2249 - <a class="button button-secondary <?php echo ( $active_page_num == $pages_number ) ? ' disabled' : ''; ?>"
2250 - href="<?php echo $bk_admin_url; ?>&page_num=<?php if ($active_page_num == $pages_number) { echo $active_page_num; } else { echo ($active_page_num+1); } echo $url_sufix; ?>">
2251 - <?php _e('Next', 'booking'); ?>
744 + <a class="button button-secondary <?php
745 + echo ( $active_page_num == $pages_number ) ? ' disabled' : ''; ?>"
746 + href="<?php
747 + echo esc_url( $bk_admin_url ); ?>&page_num=<?php
748 + if ( $active_page_num == $pages_number ) {
749 + echo esc_attr( $active_page_num );
750 + } else {
751 + echo esc_attr( $active_page_num + 1 );
752 + }
753 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
754 + echo $url_sufix; ?>">
755 + <?php
756 + esc_html_e( 'Next', 'booking' ); ?>
2252 757 </a>
2253 - <?php } ?>
758 + <?php
759 + }
760 + ?>
2254 761
2255 762 </div>
2256 763 </nav>
2257 764 </div>
@@ -2263,483 +770,8 @@
2263 770
2264 771 // </editor-fold>
2265 772
2266 773
2267 - // <editor-fold defaultstate="collapsed" desc=" == DB - cheking if table, field or index exists == " >
2268 -
2269 - /**
2270 - * Check if table exist
2271 - *
2272 - * @global $wpdb
2273 - * @param string $tablename
2274 - * @return 0|1
2275 - */
2276 - function wpbc_is_table_exists( $tablename ) {
2277 -
2278 - global $wpdb;
2279 -
2280 - if (
2281 - ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) )
2282 - || ( '_' == $wpdb->prefix ) //FixIn: 8.7.3.16
2283 - ) {
2284 - $tablename = $wpdb->prefix . $tablename;
2285 - }
2286 -
2287 - if ( 0 ) {
2288 - $sql_check_table = $wpdb->prepare( "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = '{$wpdb->dbname}') AND (TABLE_NAME = %s);", $tablename );
2289 -
2290 - $res = $wpdb->get_results( $sql_check_table );
2291 -
2292 - return count( $res );
2293 -
2294 - } else {
2295 -
2296 - $sql_check_table = $wpdb->prepare("SHOW TABLES LIKE %s" , $tablename ); //FixIn: 5.4.3
2297 -
2298 - $res = $wpdb->get_results( $sql_check_table );
2299 -
2300 - return count( $res );
2301 - }
2302 -
2303 - }
2304 -
2305 -
2306 - //FixIn: 10.0.0.1
2307 - /**
2308 - * Check if we are in playground.wordpress.net , where used 'sqlite' DB
2309 - *
2310 - * @return bool
2311 - */
2312 - function wpbc_is_this_wp_playground_db(){
2313 -
2314 - return false;
2315 -
2316 - if (
2317 - ( ( function_exists( 'sqlite_open' ) ) || ( class_exists( 'SQLite3' ) ) )
2318 - && ( ! class_exists( 'wpdev_bk_personal' ) )
2319 - ){
2320 - return true;
2321 - } else {
2322 - return false;
2323 - }
2324 - }
2325 -
2326 -
2327 - /**
2328 - * Check if table exist
2329 - *
2330 - * @global $wpdb
2331 - * @param string $tablename
2332 - * @param $fieldname
2333 - * @return 0|1
2334 - */
2335 - function wpbc_is_field_in_table_exists( $tablename , $fieldname) {
2336 -
2337 - if ( wpbc_is_this_wp_playground_db() ) {
2338 - return 1; // Probably we are in playground.wordpress.net --> So then all such fields already was created //FixIn: 10.0.0.1
2339 - }
2340 -
2341 - global $wpdb;
2342 -
2343 - if (
2344 - ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) )
2345 - || ( '_' == $wpdb->prefix ) //FixIn: 8.7.3.16
2346 - ) {
2347 - $tablename = $wpdb->prefix . $tablename;
2348 - }
2349 -
2350 - if ( 0 ) {
2351 -
2352 - $sql_check_table = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='{$tablename}' AND TABLE_SCHEMA='{$wpdb->dbname}' ";
2353 -
2354 - $res = $wpdb->get_results( $sql_check_table );
2355 -
2356 - foreach ( $res as $fld ) {
2357 - if ( $fieldname === $fld->COLUMN_NAME ) {
2358 - return 1;
2359 - }
2360 - }
2361 -
2362 - } else {
2363 -
2364 - $sql_check_table = "SHOW COLUMNS FROM {$tablename}";
2365 -
2366 - $res = $wpdb->get_results( $sql_check_table );
2367 -
2368 - foreach ( $res as $fld ) {
2369 - if ( $fld->Field == $fieldname ) {
2370 - return 1;
2371 - }
2372 - }
2373 - }
2374 -
2375 - return 0;
2376 - }
2377 -
2378 -
2379 - /**
2380 - * Check if index exist
2381 - *
2382 - * @global $wpdb
2383 - * @param string $tablename
2384 - * @param $fieldindex
2385 - * @return 0|1
2386 - */
2387 - function wpbc_is_index_in_table_exists( $tablename , $fieldindex) {
2388 - global $wpdb;
2389 - if ( (! empty($wpdb->prefix) ) && ( strpos($tablename, $wpdb->prefix) === false ) ) $tablename = $wpdb->prefix . $tablename ;
2390 - $sql_check_table = $wpdb->prepare("SHOW INDEX FROM {$tablename} WHERE Key_name = %s", $fieldindex );
2391 - $res = $wpdb->get_results( $sql_check_table );
2392 - if (count($res)>0) return 1;
2393 - else return 0;
2394 - }
2395 -
2396 - // </editor-fold>
2397 -
2398 -
2399 - // <editor-fold defaultstate="collapsed" desc=" == Security: Escaping & Sanitizing == " >
2400 -
2401 -
2402 - /**
2403 - * Sanitize $_GET, $_POST, $_REQUEST text parameters //FixIn: 10.0.0.12
2404 - *
2405 - * @param $value
2406 - * @param $keep_newlines bool
2407 - *
2408 - * @return string
2409 - */
2410 - function wpbc_clean_text_value( $value , $keep_newlines = false ){
2411 -
2412 - if ( $keep_newlines ) {
2413 - $value_cleaned = sanitize_textarea_field( $value );
2414 - } else {
2415 - $value_cleaned = sanitize_text_field( $value );
2416 - }
2417 -
2418 - return $value_cleaned;
2419 - }
2420 -
2421 -
2422 - // check $value for injection here
2423 - function wpbc_clean_parameter( $value, $is_escape_sql = true ) {
2424 -
2425 - $value = preg_replace( '/<[^>]*>/', '', $value ); // clean any tags
2426 - $value = str_replace( '<', ' ', $value );
2427 - $value = str_replace( '>', ' ', $value );
2428 - $value = strip_tags( $value );
2429 -
2430 - //FixIn: 9.7.4.1 - escape coded html/xss // Escape any XSS injection
2431 - $value = sanitize_textarea_field( $value );
2432 - $value = sanitize_textarea_field( html_entity_decode( $value ) ); // If we have field converted to 'Unicode Hex Character Code', then we make HTML decode firstly (html_entity_decode) and then make sanitizing
2433 -
2434 - if ( $is_escape_sql ) {
2435 - $value = esc_sql( $value ); // Clean SQL injection //FixIn: 9.7.4.2
2436 - }
2437 -
2438 - $value = esc_textarea( $value ); //FixIn: 7.1.1.2
2439 -
2440 - return $value;
2441 - }
2442 -
2443 -
2444 - /**
2445 - * Check paramter if it number or comma separated list of numbers
2446 - *
2447 - * @global type $wpdb
2448 - * @param string $value
2449 - * @return string
2450 - *
2451 - * Exmaple:
2452 - wpbc_clean_digit_or_csd( '12,a,45,9' ) => '12,0,45,9'
2453 - * or
2454 - wpbc_clean_digit_or_csd( '10a' ) => '10
2455 - * or
2456 - wpbc_clean_digit_or_csd( array( '12,a,45,9', '10a' ) ) => array ( '12,0,45,9', '10' )
2457 - */
2458 - function wpbc_clean_digit_or_csd( $value ) { //FixIn:6.2.1.4
2459 -
2460 - if ( $value === '' ) return $value;
2461 -
2462 -
2463 - if ( is_array( $value ) ) {
2464 - foreach ( $value as $key => $check_value ) {
2465 - $value[ $key ] = wpbc_clean_digit_or_csd( $check_value );
2466 - }
2467 - return $value;
2468 - }
2469 -
2470 - $value = str_replace( ';', ',', $value );
2471 -
2472 - $array_of_nums = explode(',', $value);
2473 -
2474 - $result = array();
2475 - foreach ($array_of_nums as $check_element) {
2476 -
2477 - $result[] = intval( $check_element ); //FixIn: 8.0.2.10
2478 - }
2479 - $result = implode(',', $result );
2480 - return $result;
2481 - }
2482 -
2483 -
2484 - /**
2485 - * Cehck about Valid date, like 2016-07-20 or digit
2486 - *
2487 - * @param string $value
2488 - * @return string or int
2489 - */
2490 - function wpbc_clean_digit_or_date( $value ) { //FixIn:6.2.1.4
2491 -
2492 - if ( $value === '' ) return $value;
2493 -
2494 - if ( preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $value ) ) {
2495 -
2496 - return $value; // Date is valid in format: 2016-07-20
2497 - } else {
2498 - return intval( $value );
2499 - }
2500 -
2501 - }
2502 -
2503 -
2504 - /**
2505 - * Check about Valid dat in format '2024-05-08' otherwise return ''
2506 - *
2507 - * @param string $value
2508 - *
2509 - * @return string date or '' if date was not valie
2510 - */
2511 - function wpbc_clean_date( $value ) {
2512 -
2513 - if (
2514 - ( ! empty( $value ) )
2515 - && ( preg_match( "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $value ) )
2516 - ){
2517 - return $value; // Date is valid in format: 2024-05-08
2518 - }
2519 -
2520 - return ''; // Date not Valid
2521 - }
2522 -
2523 -
2524 - /**
2525 - * Escape any XSS injection from values in booking form
2526 - *
2527 - * @param array $structured_booking_data_arr [...]
2528 - *
2529 - * @return array [...]
2530 - */
2531 - function wpbc_escape_any_xss_in_arr( $structured_booking_data_arr ) {
2532 -
2533 - foreach ( $structured_booking_data_arr as $field_name => $field_value ) {
2534 -
2535 - if ( is_array( $field_value ) ) {
2536 -
2537 - $structured_booking_data_arr[ $field_name ] = wpbc_escape_any_xss_in_arr( $field_value );
2538 -
2539 - } else {
2540 - $is_escape_sql = false; // Do not replace %
2541 - $field_value_cleaned = wpbc_escape_any_xss_in_string( $field_value, $is_escape_sql );
2542 - $structured_booking_data_arr[ $field_name ] = $field_value_cleaned;
2543 - }
2544 - }
2545 -
2546 - return $structured_booking_data_arr;
2547 - }
2548 -
2549 -
2550 - /**
2551 - * Escape any XSS injection from string values
2552 - *
2553 - * @param string $field_value
2554 - *
2555 - * @return string
2556 - */
2557 - function wpbc_escape_any_xss_in_string( $field_value, $is_escape_sql = true ) {
2558 -
2559 - $field_value_cleaned = wpbc_clean_parameter( $field_value, $is_escape_sql );
2560 - $field_value_cleaned = str_replace( '%', '&#37;', $field_value_cleaned ); // clean % in form, because can be problems with SQL prepare function
2561 -
2562 - return $field_value_cleaned;
2563 - }
2564 -
2565 -
2566 - function wpbc_esc_like( $value_trimmed ) {
2567 -
2568 - global $wpdb;
2569 - if ( method_exists( $wpdb ,'esc_like' ) )
2570 - return $wpdb->esc_like( $value_trimmed ); // Its require minimum WP 4.0.0
2571 - else
2572 - return addcslashes( $value_trimmed, '_%\\' ); // Direct implementation from $wpdb->esc_like(
2573 - }
2574 -
2575 -
2576 - /**
2577 - * Sanitize term to Slug format (no spaces, lowercase).
2578 - * urldecode - reverse munging of UTF8 characters.
2579 - *
2580 - * @param mixed $value
2581 - * @return string
2582 - */
2583 - function wpbc_get_slug_format( $value ) {
2584 - return urldecode( sanitize_title( $value ) );
2585 - }
2586 -
2587 -
2588 - /**
2589 - * Clean user string for using in SQL LIKE statement - append to LIKE sql
2590 - *
2591 - * @param string $value - to clean
2592 - * @return string - escaped
2593 - * Exmaple:
2594 - * $search_escaped_like_title = wpbc_clean_like_string_for_append_in_sql_for_db( $input_var );
2595 - *
2596 - * $where_sql = " WHERE title LIKE ". $search_escaped_like_title ." ";
2597 - */
2598 - function wpbc_clean_like_string_for_append_in_sql_for_db( $value ) {
2599 - global $wpdb;
2600 -
2601 - $value_trimmed = trim( stripslashes( $value ) );
2602 - $wild = '%';
2603 - $like = $wild . wpbc_esc_like( $value_trimmed ) . $wild;
2604 - $sql = $wpdb->prepare( "'%s'", $like );
2605 -
2606 - return $sql;
2607 -
2608 -
2609 - /* Help:
2610 - * First half of escaping for LIKE special characters % and _ before preparing for MySQL.
2611 - * Use this only before wpdb::prepare() or esc_sql(). Reversing the order is very bad for security.
2612 - *
2613 - * Example Prepared Statement:
2614 - *
2615 - * $wild = '%';
2616 - * $find = 'only 43% of planets';
2617 - * $like = $wild . wpbc_esc_like( $find ) . $wild;
2618 - * $sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_content LIKE '%s'", $like );
2619 - *
2620 - * Example Escape Chain:
2621 - *
2622 - * $sql = esc_sql( wpbc_esc_like( $input ) );
2623 - */
2624 -
2625 - }
2626 -
2627 -
2628 - /**
2629 - * Clean string for using in SQL LIKE requests inside single quotes: WHERE title LIKE '%". $escaped_search_title ."%'
2630 - * Replaced _ to \_ % to \% \ to \\
2631 - * @param string $value - to clean
2632 - * @return string - escaped
2633 - * Exmaple:
2634 - * $search_escaped_like_title = wpbc_clean_like_string_for_db( $input_var );
2635 - *
2636 - * $where_sql = " WHERE title LIKE '%". $search_escaped_like_title ."%' ";
2637 - *
2638 - * Important! Use SINGLE quotes after in SQL query: LIKE '%".$data."%'
2639 - */
2640 - function wpbc_clean_like_string_for_db( $value ){
2641 -
2642 - global $wpdb;
2643 -
2644 - $value_trimmed = trim( stripslashes( $value ) );
2645 -
2646 - $value_trimmed = wpbc_esc_like( $value_trimmed );
2647 -
2648 - $value = trim( $wpdb->prepare( "'%s'", $value_trimmed ) , "'" );
2649 -
2650 - return $value;
2651 -
2652 - /* Help:
2653 - * First half of escaping for LIKE special characters % and _ before preparing for MySQL.
2654 - * Use this only before wpdb::prepare() or esc_sql(). Reversing the order is very bad for security.
2655 - *
2656 - * Example Prepared Statement:
2657 - *
2658 - * $wild = '%';
2659 - * $find = 'only 43% of planets';
2660 - * $like = $wild . wpbc_esc_like( $find ) . $wild;
2661 - * $sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_content LIKE '%s'", $like );
2662 - *
2663 - * Example Escape Chain:
2664 - *
2665 - * $sql = esc_sql( wpbc_esc_like( $input ) );
2666 - */
2667 - }
2668 -
2669 -
2670 - /**
2671 - * Escape string from SQL for the HTML form field
2672 - *
2673 - * @param string $value
2674 - * @return string
2675 - *
2676 - * Used: esc_sql function.
2677 - *
2678 - * https://codex.wordpress.org/Function_Reference/esc_sql
2679 - * Note: Be careful to use this function correctly. It will only escape values to be used in strings in the query.
2680 - * That is, it only provides escaping for values that will be within quotes in the SQL (as in field = '{$escaped_value}').
2681 - * If your value is not going to be within quotes, your code will still be vulnerable to SQL injection.
2682 - * For example, this is vulnerable, because the escaped value is not surrounded by quotes in the SQL query:
2683 - * ORDER BY {$escaped_value}. As such, this function does not escape unquoted numeric values, field names, or SQL keywords.
2684 - *
2685 - */
2686 - function wpbc_clean_string_for_form( $value ){
2687 -
2688 - global $wpdb;
2689 -
2690 - $value_trimmed = trim( stripslashes( $value ) );
2691 -
2692 - //FixIn: 8.0.2.10 //Fix for update of WP 4.8.3
2693 - if ( method_exists( $wpdb, 'remove_placeholder_escape' ) )
2694 - $esc_sql_value = $wpdb->remove_placeholder_escape( esc_sql( $value_trimmed ) );
2695 - else
2696 - $esc_sql_value = esc_sql( $value_trimmed );
2697 -
2698 - //$value = trim( $wpdb->prepare( "'%s'", $esc_sql_value ) , "'" );
2699 -
2700 - $esc_sql_value = trim( stripslashes( $esc_sql_value ) );
2701 -
2702 - return $esc_sql_value;
2703 -
2704 - }
2705 -
2706 -
2707 - /**
2708 - * Escape shortcode parameters
2709 - *
2710 - * @param array $attr
2711 - *
2712 - * @return array
2713 - */
2714 - function wpbc_escape_shortcode_params( $attr ) { //FixIn: 9.7.3.6.1
2715 -
2716 - if ( is_array( $attr ) ) {
2717 -
2718 - $scaped_attr = array();
2719 -
2720 - foreach ( $attr as $attr_key => $attr_val ) {
2721 - $attr_key = esc_attr( $attr_key );
2722 - $attr_val = esc_attr( $attr_val );
2723 - $scaped_attr[ $attr_key ] = $attr_val;
2724 - }
2725 - return $scaped_attr;
2726 - }
2727 -
2728 - if ( is_string( $attr ) ) { //FixIn: 9.7.3.6.2
2729 -
2730 - $scaped_attr = esc_attr( $attr );
2731 -
2732 - return $scaped_attr;
2733 - }
2734 -
2735 - return $attr;
2736 - }
2737 -
2738 -
2739 - // </editor-fold>
2740 -
2741 -
2742 774 // <editor-fold defaultstate="collapsed" desc=" == Number of New Bookings == " >
2743 775
2744 776 /**
2745 777 * Reset Cache for getting Number of new bookings. After this operation, system will get number of new bookings from the DB.
@@ -2758,229 +790,80 @@
2758 790 add_action( 'wpbc_set_booking_as_read', 'wpbc_booking_cache__new_bookings__reset' );
2759 791 add_action( 'wpbc_set_booking_as_unread', 'wpbc_booking_cache__new_bookings__reset' );
2760 792
2761 793
2762 - /**
2763 - * Get number of new bookings
2764 - * @return false|int|mixed|null
2765 - */
2766 - function wpbc_db_get_number_new_bookings(){
794 +/**
795 + * Get number of new bookings
796 + * @return false|int|mixed|null
797 + */
798 +function wpbc_db_get_number_new_bookings() {
2767 799
2768 - $new_bookings__number = get_bk_option( 'booking_cache__new_bookings__number' );
2769 - $new_bookings__saved_date = get_bk_option( 'booking_cache__new_bookings__saved_date' );
800 + $new_bookings__number = get_bk_option( 'booking_cache__new_bookings__number' );
801 + $new_bookings__saved_date = get_bk_option( 'booking_cache__new_bookings__saved_date' );
2770 802
2771 - $nowdate_str_ymdhis = date( 'Y-m-d H:i:s', strtotime( 'now' ) );
803 + $nowdate_str_ymdhis = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
2772 804
2773 - if ( ! empty( $new_bookings__saved_date ) ) {
805 + if ( ! empty( $new_bookings__saved_date ) ) {
2774 806
2775 - $is_expired = ( strtotime( $new_bookings__saved_date ) <= strtotime( '-10 minutes', strtotime( $nowdate_str_ymdhis ) ) );
807 + $is_expired = ( strtotime( $new_bookings__saved_date ) <= strtotime( '-10 minutes', strtotime( $nowdate_str_ymdhis ) ) );
2776 808
2777 - if ( ! $is_expired ) {
2778 - return $new_bookings__number;
2779 - }
2780 - }
2781 -
2782 - if ( 1 ) {
2783 - global $wpdb;
2784 -
2785 - //if ( wpbc_is_field_in_table_exists('booking','is_new') == 0 ) return 0; // do not created this field, so return 0
2786 -
2787 - $trash_bookings = ' AND bk.trash != 1 '; //FixIn: 6.1.1.10 - check also below usage of {$trash_bookings}
2788 - $sql_req = "SELECT bk.booking_id FROM {$wpdb->prefix}booking as bk WHERE bk.is_new = 1 {$trash_bookings} ";
2789 -
2790 - $sql_req = apply_bk_filter( 'get_sql_for_checking_new_bookings', $sql_req );
2791 - $sql_req = apply_bk_filter( 'get_sql_for_checking_new_bookings_multiuser', $sql_req );
2792 -
2793 - $bookings = $wpdb->get_results( $sql_req );
2794 - $bookings_count = count( $bookings );
2795 - }
2796 -
2797 -
2798 - update_bk_option( 'booking_cache__new_bookings__number', $bookings_count );
2799 - update_bk_option( 'booking_cache__new_bookings__saved_date', $nowdate_str_ymdhis );
2800 -
2801 - return $bookings_count;
809 + if ( ! $is_expired ) {
810 + return $new_bookings__number;
2802 811 }
2803 -
2804 -
2805 - /**
2806 - * Update 'is_new' status of bookings in Database
2807 - *
2808 - * @param $id_of_new_bookings inr or comma seperated ID of bookings. Example: '1' | '3,5,7,9'
2809 - * @param $is_new '0' | '1'
2810 - * @param $user_id 'user_id'
2811 - *
2812 - */
2813 - function wpbc_db_update_number_new_bookings( $id_of_new_bookings, $is_new = '0' , $user_id = 1 ){
2814 - global $wpdb;
2815 -
2816 - if (count($id_of_new_bookings) > 0 ) {
2817 -
2818 - //if (wpbc_is_field_in_table_exists('booking','is_new') == 0) return 0; // do not created this field, so return 0
2819 -
2820 - $id_of_new_bookings = implode(',', $id_of_new_bookings);
2821 - $id_of_new_bookings = wpbc_clean_like_string_for_db( $id_of_new_bookings );
2822 -
2823 -
2824 - //debuge($id_of_new_bookings);
2825 - if ($id_of_new_bookings == 'all') {
2826 - $update_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.is_new = {$is_new} WHERE bk.is_new != {$is_new} "; //FixIn: 8.2.1.18
2827 - //debuge($update_sql);
2828 - $update_sql = apply_bk_filter('update_sql_for_checking_new_bookings', $update_sql, 0 , $user_id );
2829 - } else
2830 - $update_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.is_new = {$is_new} WHERE bk.booking_id IN ( {$id_of_new_bookings} ) ";
2831 -
2832 - if ( false === $wpdb->query( $update_sql ) ) {
2833 - debuge_error('Error during updating status of bookings at DB',__FILE__,__LINE__);
2834 - die();
2835 - }
2836 - }
2837 - }
812 + }
2838 813
2839 - // </editor-fold>
814 + global $wpdb;
2840 815
816 + $trash_bookings = ' AND bk.trash != 1 '; // FixIn: 6.1.1.10 - check also below usage of {$trash_bookings} .
817 + $sql_req = "SELECT bk.booking_id FROM {$wpdb->prefix}booking as bk WHERE bk.is_new = 1 {$trash_bookings} ";
2841 818
2842 - // <editor-fold defaultstate="collapsed" desc=" == Requests: News , Version == " >
819 + $sql_req = apply_bk_filter( 'get_sql_for_checking_new_bookings', $sql_req );
820 + $sql_req = apply_bk_filter( 'get_sql_for_checking_new_bookings_multiuser', $sql_req );
821 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
822 + $bookings = $wpdb->get_results( $sql_req );
823 + $bookings_count = count( $bookings );
2843 824
2844 - define ('OBC_CHECK_URL', 'https://wpbookingcalendar.com/');
825 + update_bk_option( 'booking_cache__new_bookings__number', $bookings_count );
826 + update_bk_option( 'booking_cache__new_bookings__saved_date', $nowdate_str_ymdhis );
2845 827
828 + return $bookings_count;
829 +}
2846 830
2847 - function wpdev_ajax_check_bk_news( $sub_url = '' ){
2848 831
2849 - $v=array();
2850 - if (class_exists('wpdev_bk_personal')) $v[] = 'wpdev_bk_personal';
2851 - if (class_exists('wpdev_bk_biz_s')) $v[] = 'wpdev_bk_biz_s';
2852 - if (class_exists('wpdev_bk_biz_m')) $v[] = 'wpdev_bk_biz_m';
2853 - if (class_exists('wpdev_bk_biz_l')) $v[] = 'wpdev_bk_biz_l';
2854 - if (class_exists('wpdev_bk_multiuser')) $v[] = 'wpdev_bk_multiuser';
832 +/**
833 + * Update 'is_new' status of bookings in Database
834 + *
835 + * @param $id_of_new_bookings inr or comma seperated ID of bookings. Example: '1' | '3,5,7,9'
836 + * @param $is_new '0' | '1'
837 + * @param $user_id 'user_id'
838 + *
839 + */
840 +function wpbc_db_update_number_new_bookings( $id_of_new_bookings, $is_new = '0', $user_id = 1 ) {
2855 841
2856 - $obc_settings = array();
2857 - $ver = get_bk_option('bk_version_data');
2858 - if ( $ver !== false ) { $obc_settings = array( 'subscription_key'=>wp_json_encode($ver) ); }
842 + global $wpdb;
2859 843
2860 - $params = array(
2861 - 'action' => 'get_news',
2862 - 'subscription_email' => isset($obc_settings['subscription_email'])?$obc_settings['subscription_email']:false,
2863 - 'subscription_key' => isset($obc_settings['subscription_key'])?$obc_settings['subscription_key']:false,
2864 - 'bk' => array('bk_ver'=>WPDEV_BK_VERSION, 'bk_url'=>WPBC_PLUGIN_URL,'bk_dir'=>WPBC_PLUGIN_DIR, 'bk_clss'=>$v),
2865 - 'siteurl' => get_option('siteurl'),
2866 - 'siteip' => wpbc_get_server_ip(), //FixIn: 9.8.14.3
2867 - 'admin_email' => get_option('admin_email')
2868 - );
844 + if ( count( $id_of_new_bookings ) > 0 ) {
2869 845
2870 - $request = new WP_Http();
2871 - if (empty($sub_url)) $sub_url = 'info/';
2872 - $result = $request->request( OBC_CHECK_URL . $sub_url, array(
2873 - 'method' => 'POST',
2874 - 'timeout' => 15,
2875 - 'body' => $params
2876 - ));
846 + $id_of_new_bookings = implode( ',', $id_of_new_bookings );
847 + $id_of_new_bookings = wpbc_clean_like_string_for_db( $id_of_new_bookings );
2877 848
2878 - if (!is_wp_error($result) && ($result['response']['code']=='200') && (true) ) {
849 + // FixIn: 10.12.1.5.
850 + if ( 'all' === $id_of_new_bookings ) {
851 + $update_sql = "UPDATE {$wpdb->prefix}booking SET is_new = {$is_new} WHERE is_new != {$is_new} "; // FixIn: 8.2.1.18.
2879 852
2880 - $string = ($result['body']); //$string = str_replace( "'", '&#039;', $string );
2881 - echo $string;
2882 - echo ' <script type="text/javascript"> ';
2883 - echo ' jQuery("#ajax_bk_respond").after( jQuery("#ajax_bk_respond #bk_news_loaded") );';
2884 - echo ' jQuery("#bk_news_loaded").slideUp(1).slideDown(1500);';
2885 - echo ' </script> ';
2886 -
2887 - } else /**/
2888 - { // Some error appear
2889 - echo '<div id="bk_errror_loading">';
2890 - if (is_wp_error($result)) echo $result->get_error_message();
2891 - else echo $result['response']['message'];
2892 - echo '</div>';
2893 - echo ' <script type="text/javascript"> ';
2894 - echo ' document.getElementById("bk_news").style.display="none";';
2895 - echo ' jQuery("#ajax_bk_respond").after( jQuery("#ajax_bk_respond #bk_errror_loading") );';
2896 - echo ' jQuery("#bk_errror_loading").slideUp(1).slideDown(1500);';
2897 - echo ' jQuery("#bk_news_section").animate({opacity:1},3000).slideUp(1500);';
2898 - echo ' </script> ';
2899 - }
2900 -
853 + $update_sql = apply_bk_filter( 'update_sql_for_checking_new_bookings', $update_sql, 0, $user_id );
854 + } else {
855 + $update_sql = "UPDATE {$wpdb->prefix}booking SET is_new = {$is_new} WHERE booking_id IN ( {$id_of_new_bookings} ) ";
2901 856 }
2902 857
2903 -
2904 - /**
2905 - * Check if user defined to not show up_news section.
2906 - *
2907 - */
2908 - function wpbc_is_show_up_news(){ //FixIn: 8.1.3.9
2909 -
2910 - $wpdev_copyright_adminpanel = get_bk_option( 'booking_wpdev_copyright_adminpanel' ); // check
2911 - if ( ( $wpdev_copyright_adminpanel === 'Off' )
2912 - && ( ! wpbc_is_this_demo() )
2913 - && ( class_exists('wpdev_bk_personal') )
2914 - ) {
2915 - return false;
2916 - } else {
2917 - return true;
2918 - }
858 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
859 + if ( false === $wpdb->query( $update_sql ) ) {
860 + debuge_error( 'Error during updating status of bookings at DB', __FILE__, __LINE__ );
861 + die();
2919 862 }
863 + }
864 +}
2920 865
2921 -
2922 - function wpdev_ajax_check_bk_version(){
2923 - $v=array();
2924 - if (class_exists('wpdev_bk_personal')) $v[] = 'wpdev_bk_personal';
2925 - if (class_exists('wpdev_bk_biz_s')) $v[] = 'wpdev_bk_biz_s';
2926 - if (class_exists('wpdev_bk_biz_m')) $v[] = 'wpdev_bk_biz_m';
2927 - if (class_exists('wpdev_bk_biz_l')) $v[] = 'wpdev_bk_biz_l';
2928 - if (class_exists('wpdev_bk_multiuser')) $v[] = 'wpdev_bk_multiuser';
2929 -
2930 - $obc_settings = array();
2931 - $params = array(
2932 - 'action' => 'set_register',
2933 - 'order_number' => isset($_POST['order_num'])?$_POST['order_num']:false,
2934 - 'bk' => array('bk_ver'=>WPDEV_BK_VERSION, 'bk_url'=>WPBC_PLUGIN_URL,'bk_dir'=>WPBC_PLUGIN_DIR, 'bk_clss'=>$v),
2935 - 'siteurl' => get_option('siteurl'),
2936 - 'siteip' => wpbc_get_server_ip(), //FixIn: 9.8.14.3
2937 - 'admin_email' => get_option('admin_email')
2938 - );
2939 -
2940 - update_bk_option( 'bk_version_data' , serialize($params) );
2941 -
2942 - $request = new WP_Http();
2943 - $result = $request->request( OBC_CHECK_URL . 'register/', array(
2944 - 'method' => 'POST',
2945 - 'timeout' => 15,
2946 - 'body' => $params
2947 - ));
2948 -
2949 - if ( ! is_wp_error($result)
2950 - && ( $result['response']['code']=='200' )
2951 - && ( true ) ) {
2952 -
2953 - $string = ($result['body']); //$string = str_replace( "'", '&#039;', $string );
2954 - echo $string ;
2955 - echo ' <script type="text/javascript"> ';
2956 - echo ' jQuery("#ajax_message").append( jQuery("#ajax_respond #bk_registration_info") );';
2957 - echo ' jQuery("#ajax_message").append( "<div id=\'bk_registration_info_reload\'>If page will not reload automatically, please refresh page after 60 seconds...</div>" );';
2958 - echo ' </script> ';
2959 -
2960 - } else /**/
2961 - { // Some error appear
2962 - echo '<div id="bk_errror_loading" class="warning_message" >';
2963 - echo '<div class="info_message">'; _e('Warning! Some error occur, during sending registration request.' ,'booking'); echo '</div>';
2964 -
2965 - if (is_wp_error($result)) echo $result->get_error_message();
2966 - else echo $result['response']['message'];
2967 - echo '<br /><br />';
2968 - _e('Please refresh this page and if the same error appear again contact support by email (with info about order number and website) for finishing the registrations' ,'booking'); echo ' <a href="mailto:activate@wpbookingcalendar.com">activate@wpbookingcalendar.com</a>';
2969 - echo '</strong></div>';
2970 - echo ' <script type="text/javascript"> ';
2971 - echo ' jQuery( "#ajax_message" ).html( "" );';
2972 -
2973 - echo ' jQuery("#ajax_message").append( jQuery("#ajax_respond #bk_errror_loading") );';
2974 - echo ' jQuery("#bk_errror_loading").slideUp(1).slideDown(1500);';
2975 -
2976 - echo ' jQuery("#recheck_version").animate({opacity:1},3000).slideUp(1500);';
2977 - echo ' </script> ';
2978 - }
2979 -
2980 -
2981 - }
2982 -
2983 866 // </editor-fold>
2984 867
2985 868
2986 869 // <editor-fold defaultstate="collapsed" desc=" == User ID | Role - functions == " >
@@ -3006,9 +889,9 @@
3006 889 * Get Current ID of user or get user ID of Forced log in user in Booking Calendar MultiUser version.
3007 890 *
3008 891 * @return int
3009 892 */
3010 - function wpbc_get_current_user_id() { //FixIn: 9.2.4.1
893 + function wpbc_get_current_user_id() { // FixIn: 9.2.4.1.
3011 894
3012 895 if ( function_exists( 'wpbc_mu__wp_get_current_user' ) ) {
3013 896 $user = wpbc_mu__wp_get_current_user();
3014 897 $user_bk_id = $user->ID;
@@ -3024,9 +907,9 @@
3024 907 * Get Current User Object or get User object of Forced log in user in Booking Calendar MultiUser version.
3025 908 *
3026 909 * @return stdClass|WP_User|null
3027 910 */
3028 - function wpbc_get_current_user() { //FixIn: 9.2.4.1
911 + function wpbc_get_current_user() { // FixIn: 9.2.4.1.
3029 912
3030 913 if ( function_exists( 'wpbc_mu__wp_get_current_user' ) ) {
3031 914 $user = wpbc_mu__wp_get_current_user();
3032 915 } else {
@@ -3060,9 +943,9 @@
3060 943 */
3061 944 function wpbc_show_message ( $message, $time_to_show , $message_type = 'updated') {
3062 945
3063 946 // Generate unique HTML ID for the message
3064 - $inner_message_id = intval( time() * rand(10, 100) );
947 + $inner_message_id = intval( time() * wp_rand(10, 100) );
3065 948
3066 949 // Get formated HTML message
3067 950 $notice = wpbc_get_formated_message( $message, $message_type, $inner_message_id );
3068 951
@@ -3071,11 +954,13 @@
3071 954
3072 955 // Show this Message
3073 956 ?> <script type="text/javascript">
3074 957 if ( jQuery('.wpbc_admin_message').length ) {
3075 - jQuery('.wpbc_admin_message').append( '<?php echo $notice; ?>' );
958 + jQuery('.wpbc_admin_message').append( '<?php
959 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
960 + echo $notice; ?>' );
3076 961 <?php if ( $time_to_show > 0 ) { ?>
3077 - jQuery('#wpbc_inner_message_<?php echo $inner_message_id; ?>').animate({opacity: 1},<?php echo $time_to_show; ?>).fadeOut( 2000 );
962 + jQuery('#wpbc_inner_message_<?php echo esc_attr( $inner_message_id ); ?>').animate({opacity: 1},<?php echo esc_attr( $time_to_show ); ?>).fadeOut( 2000 );
3078 963 <?php } ?>
3079 964 }
3080 965 </script> <?php
3081 966 }
@@ -3133,13 +1018,15 @@
3133 1018
3134 1019 $message_content .= '</div>';
3135 1020
3136 1021 $message_content .= '<div class="clear"></div>';
3137 -
3138 - if ( $is_echo )
1022 +
1023 + if ( $is_echo ) {
1024 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3139 1025 echo $message_content;
3140 - else
1026 + } else {
3141 1027 return $message_content;
1028 + }
3142 1029
3143 1030 }
3144 1031
3145 1032 // </editor-fold>
@@ -3172,9 +1059,9 @@
3172 1059 $my_close_open_win_id = $metabox_id . '_metabox';
3173 1060
3174 1061 ?>
3175 1062 <div class='meta-box'>
3176 - <div id="<?php echo $my_close_open_win_id; ?>"
1063 + <div id="<?php echo esc_attr( $my_close_open_win_id ); ?>"
3177 1064 class="<?php echo esc_attr( $params['css_class'] ); ?> <?php
3178 1065 if ( $params['is_show_minimize'] ) {
3179 1066 if ( '1' == get_user_option( 'booking_win_' . $my_close_open_win_id ) ) {
3180 1067 echo 'closed';
@@ -3180,20 +1067,37 @@
3180 1067 echo 'closed';
3181 1068 }
3182 1069 }
3183 1070 ?>"
3184 - style="<?php if ( ! $params['is_section_visible_after_load'] ) {
3185 - echo 'display:none';
3186 - }
3187 - ?>"
1071 + style="<?php
1072 +
1073 + $force_visible = false;
1074 +
1075 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
1076 + $do_expand = ( ( isset( $_REQUEST['do_expand'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['do_expand'] ) ) : '' );
1077 +
1078 + if ( $my_close_open_win_id === $do_expand ) {
1079 + $force_visible = true;
1080 + }
1081 +
1082 + if ( ( ! $params['is_section_visible_after_load'] ) && ( ! $force_visible ) ) {
1083 + echo 'display:none';
1084 + }
1085 + ?>"
3188 1086 ><div class="postbox-header" style="display: flex;flex-flow: row nowrap;border-bottom: 1px solid #ccd0d4;">
3189 1087 <h3 class='hndle' style="flex: 1 1 auto;border: none;">
3190 - <span><?php echo wp_kses_post( $title ); ?></span>
3191 - <?php echo $params['dismiss_button']; ?>
1088 + <span><?php
1089 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1090 + echo $title;
1091 + ?></span>
1092 + <?php
1093 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1094 + echo $params['dismiss_button'];
1095 + ?>
3192 1096 </h3>
3193 1097 <?php if ( $params['is_show_minimize'] ) { ?>
3194 - <div title="<?php _e('Click to toggle','booking'); ?>" class="handlediv"
3195 - onclick="javascript:wpbc_verify_window_opening(<?php echo wpbc_get_current_user_id(); ?>, '<?php echo $my_close_open_win_id; ?>');"
1098 + <div title="<?php esc_attr_e('Click to toggle','booking'); ?>" class="handlediv"
1099 + onclick="javascript:wpbc_verify_window_opening(<?php echo esc_attr( wpbc_get_current_user_id() ); ?>, '<?php echo esc_attr( $my_close_open_win_id ); ?>');"
3196 1100 ><br/></div>
3197 1101 <?php } ?>
3198 1102 </div>
3199 1103 <div class="inside">
@@ -3211,119 +1115,49 @@
3211 1115
3212 1116 // </editor-fold>
3213 1117
3214 1118
3215 - // <editor-fold defaultstate="collapsed" desc=" == Is Dismissed == " >
3216 -
3217 - /**
3218 - * Only check if Dismised or visible this section
3219 - *
3220 - * @param $element_html_id
3221 - *
3222 - * @return bool
3223 - */
3224 - function wpbc_is_dismissed_panel_visible( $element_html_id ) {
3225 - return ( '1' != get_user_option( 'booking_win_' . $element_html_id ) );
3226 -
3227 - }
3228 -
3229 - /**
3230 - * Show dismiss close button for specific HTML section
3231 - *
3232 - * @param string $element_html_id - ID of HTML selection to dismiss
3233 - * @param array $params - array( 'title' => 'Dismiss', 'is_apply_in_demo' => false ) )
3234 - *
3235 - * @return bool
3236 - *
3237 - * Examples:
3238 - * $is_dismissed = wpbc_is_dismissed( 'wpbc_dashboard_section_video_f' );
3239 - *
3240 - * $is_dismissed = wpbc_is_dismissed( 'html_id', array( 'is_apply_in_demo' => $is_apply_in_demo ) );
3241 - *
3242 - * $is_panel_visible = wpbc_is_dismissed( 'wpbc-panel-get-started', array(
3243 - * 'title' => '<i class="menu_icon icon-1x wpbc_icn_close"></i> ',
3244 - * 'hint' => __( 'Dismiss', 'booking' ),
3245 - * 'class' => 'wpbc_panel_get_started_dismiss',
3246 - * 'css' => ''
3247 - * ));
3248 - */
3249 - function wpbc_is_dismissed( $element_html_id, $params = array() ){ //FixIn: 8.1.3.10
3250 -
3251 - $defaults = array(
3252 - 'title' => '&times;'
3253 - , 'hint' => __( 'Dismiss' ,'booking')
3254 - , 'is_apply_in_demo' => ! wpbc_is_this_demo()
3255 - , 'class' => '' // CSS class of close X element
3256 - , 'css' => '' // Style class of close X element
3257 - , 'dismiss_css_class' => '' //'.'.$id . '_' . 'weekdays_conditions'
3258 - );
3259 - $params = wp_parse_args( $params, $defaults );
3260 -
3261 -
3262 - $params['css'] = 'text-decoration: none;font-weight: 600;float:right;' . $params['css']; // Append CSS instead of replace it
3263 -
3264 - if ( ( class_exists( 'WPBC_Dismiss' )) && ( $params[ 'is_apply_in_demo' ] ) ) {
3265 -
3266 - global $wpbc_Dismiss;
3267 -
3268 - $is_panel_visible = $wpbc_Dismiss->render( array(
3269 - 'id' => $element_html_id,
3270 - 'title' => $params['title'],
3271 - 'hint' => $params['hint'],
3272 - 'class' => $params['class'],
3273 - 'css' => $params['css'],
3274 - 'dismiss_css_class' => $params['dismiss_css_class']
3275 - ) );
3276 - } else {
3277 - $is_panel_visible = false;
3278 - }
3279 -
3280 - return $is_panel_visible;
3281 - }
3282 -
3283 - // </editor-fold>
3284 -
3285 -
3286 1119 // <editor-fold defaultstate="collapsed" desc=" == Inline JavaScript to Footer page == " >
3287 1120
3288 - /**
3289 - * Queue JavaScript for later output at footer
3290 - *
3291 - * @param string $code
3292 - */
3293 - function wpbc_enqueue_js( $code ) {
3294 - global $wpbc_queued_js;
1121 +/**
1122 + * Queue JavaScript for later output at footer
1123 + *
1124 + * @param string $code
1125 + */
1126 +function wpbc_enqueue_js( $code ) {
1127 + global $wpbc_queued_js;
3295 1128
3296 - if ( empty( $wpbc_queued_js ) ) {
3297 - $wpbc_queued_js = '';
3298 - }
1129 + if ( empty( $wpbc_queued_js ) ) {
1130 + $wpbc_queued_js = '';
1131 + }
3299 1132
3300 - $wpbc_queued_js .= "\n" . $code . "\n";
3301 - }
1133 + $wpbc_queued_js .= "\n" . $code . "\n";
1134 +}
3302 1135
3303 1136
3304 - /**
3305 - * Output any queued javascript code in the footer.
3306 - */
3307 - function wpbc_print_js() {
1137 +/**
1138 + * Output any queued javascript code in the footer.
1139 + */
1140 +function wpbc_print_js() {
3308 1141
3309 - global $wpbc_queued_js;
1142 + global $wpbc_queued_js;
3310 1143
3311 - if ( ! empty( $wpbc_queued_js ) ) {
1144 + if ( ! empty( $wpbc_queued_js ) ) {
3312 1145
3313 - $wpbc_queued_js = wp_check_invalid_utf8( $wpbc_queued_js );
1146 + $wpbc_queued_js = wp_check_invalid_utf8( $wpbc_queued_js );
3314 1147
3315 - $wpbc_queued_js = wp_specialchars_decode( $wpbc_queued_js , ENT_COMPAT); // Converts double quotes '&quot;' => '"'
1148 + $wpbc_queued_js = wp_specialchars_decode( $wpbc_queued_js, ENT_COMPAT ); // Converts double quotes '&quot;' => '"'.
3316 1149
3317 - $wpbc_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wpbc_queued_js );
3318 - $wpbc_queued_js = str_replace( "\r", '', $wpbc_queued_js );
1150 + $wpbc_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wpbc_queued_js );
1151 + $wpbc_queued_js = str_replace( "\r", '', $wpbc_queued_js );
3319 1152
3320 - echo "<!-- WPBC JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) {" . $wpbc_queued_js . "});\n</script>\n<!-- End WPBC JavaScript -->\n";
1153 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1154 + echo "<!-- WPBC JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) {" . $wpbc_queued_js . "});\n</script>\n<!-- End WPBC JavaScript -->\n";
3321 1155
3322 - $wpbc_queued_js = '';
3323 - unset( $wpbc_queued_js );
3324 - }
3325 - }
1156 + $wpbc_queued_js = '';
1157 + unset( $wpbc_queued_js );
1158 + }
1159 +}
3326 1160
3327 1161 // </editor-fold>
3328 1162
3329 1163
@@ -3377,8 +1211,30 @@
3377 1211 }
3378 1212 }
3379 1213 add_bk_action('wpbc_mu_set_environment_for_user', 'wpbc_mu_set_environment_for_user');
3380 1214
1215 +
1216 + /**
1217 + * Check if we have simulated user login in Booking Calendar MultiUser version
1218 + * return user ID of regular simulated user or 0 if not simulated
1219 + * @return int
1220 + */
1221 + function wpbc_mu__is_simulated_login_as_user(){
1222 + if ( class_exists( 'wpdev_bk_multiuser' ) ) {
1223 +
1224 + $real_current_user_id = get_current_user_id(); // Is current user suer booking admin and if this user was simulated log in
1225 + $is_user_super_admin = apply_bk_filter( 'is_user_super_admin', $real_current_user_id );
1226 + if ( $is_user_super_admin ) {
1227 +
1228 + $simulate_user_id = intval( get_option( 'booking_simulate_login_as_user' ) ); // Is user was simulated log in
1229 +
1230 + if ( ( ! empty( $simulate_user_id ) ) && ( $simulate_user_id > 0 ) ) {
1231 + return $simulate_user_id;
1232 + }
1233 + }
1234 + }
1235 + return 0;
1236 + }
3381 1237 // </editor-fold>
3382 1238
3383 1239
3384 1240 // <editor-fold defaultstate="collapsed" desc=" == Currency functions (>=BS) == " >
@@ -3445,9 +1301,9 @@
3445 1301 *
3446 1302 * @param int $booking_resource_id - ID of specific booking resource
3447 1303 * @return string - cost per period
3448 1304 */
3449 - function wpbc_get_cost_per_period_for_user( $booking_resource_id = 0 ){ //FixIn: 10.0.0.14
1305 + function wpbc_get_cost_per_period_for_user( $booking_resource_id = 0 ){ // FixIn: 10.0.0.14.
3450 1306
3451 1307 if ( ! class_exists( 'wpdev_bk_biz_s' ) ) {
3452 1308 return '';
3453 1309 }
@@ -3467,162 +1323,174 @@
3467 1323 // </editor-fold>
3468 1324
3469 1325
3470 1326 // <editor-fold defaultstate="collapsed" desc=" == Approve | Pending functions == " >
3471 -
3472 - /**
3473 - * Check is this booking approved -- get booking dates in DB and check status
3474 - *
3475 - * @param $booking_id
3476 - *
3477 - * @return bool
3478 - */
3479 - function wpbc_is_booking_approved( $booking_id ){ //FixIn: 8.1.2.8
3480 -
3481 - $is_booking_approved = false;
3482 -
3483 - global $wpdb;
3484 -
3485 - $sql = $wpdb->prepare( "SELECT DISTINCT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id = %d ORDER BY booking_date", $booking_id );
3486 -
3487 - $dates_result = $wpdb->get_results( $sql );
3488 -
3489 - foreach ( $dates_result as $my_date ) {
3490 -
3491 - if ( '1' == $my_date->approved ) {
3492 - $is_booking_approved = true; //FixIn: 8.3.1.2
3493 - }
3494 - }
3495 -
3496 - return $is_booking_approved;
1327 +
1328 +/**
1329 + * Check is this booking approved -- get booking dates in DB and check status
1330 + *
1331 + * @param $booking_id
1332 + *
1333 + * @return bool
1334 + */
1335 +function wpbc_is_booking_approved( $booking_id ) {
1336 + // FixIn: 8.1.2.8.
1337 +
1338 + $is_booking_approved = false;
1339 +
1340 + global $wpdb;
1341 +
1342 + $sql = $wpdb->prepare( "SELECT DISTINCT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id = %d ORDER BY booking_date", $booking_id );
1343 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
1344 + $dates_result = $wpdb->get_results( $sql );
1345 +
1346 + foreach ( $dates_result as $my_date ) {
1347 +
1348 + if ( 1 === intval( $my_date->approved ) ) {
1349 + $is_booking_approved = true; // FixIn: 8.3.1.2.
3497 1350 }
3498 -
3499 -
3500 - /**
3501 - * Approve booking in DB (update booking dates in DB like approved = '1')
3502 - *
3503 - * @param $booking_id int | CSD e.g. 100 | '1,5,10'
3504 - *
3505 - * @return bool
3506 - */
3507 - function wpbc_db__booking_approve( $booking_id ) {
3508 -
3509 - $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers
3510 -
3511 - global $wpdb;
3512 -
3513 - $update_sql = "UPDATE {$wpdb->prefix}bookingdates SET approved = '1' WHERE booking_id IN ({$booking_id});";
3514 -
3515 - if ( false === $wpdb->query( $update_sql ) ) {
3516 - return false;
1351 + }
1352 +
1353 + return $is_booking_approved;
1354 +}
1355 +
1356 +
1357 +/**
1358 + * Approve booking in DB (update booking dates in DB like approved = '1')
1359 + *
1360 + * @param $booking_id int | CSD e.g. 100 | '1,5,10'
1361 + *
1362 + * @return bool
1363 + */
1364 +function wpbc_db__booking_approve( $booking_id ) {
1365 +
1366 + $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check parameter if it number or comma separated list of numbers.
1367 +
1368 + global $wpdb;
1369 +
1370 + $update_sql = "UPDATE {$wpdb->prefix}bookingdates SET approved = '1' WHERE booking_id IN ({$booking_id});";
1371 +
1372 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
1373 + if ( false === $wpdb->query( $update_sql ) ) {
1374 + return false;
1375 + }
1376 +
1377 + // In case if the booking was in Trash, then restore it.
1378 + // FixIn: 10.8.1.1.
1379 +
1380 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
1381 + if ( false === $wpdb->query( "UPDATE {$wpdb->prefix}booking SET trash = 0 WHERE booking_id IN ({$booking_id})" ) ) {
1382 + return false;
1383 + }
1384 +
1385 + return true;
1386 +}
1387 +
1388 +
1389 +/**
1390 + * Approve specific booking and send email about this.
1391 + *
1392 + * @param int $booking_id - ID of booking
1393 + * @param string $email_reason
1394 + */
1395 +function wpbc_auto_approve_booking( $booking_id, $email_reason = '' ) {
1396 +
1397 + $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers.
1398 +
1399 + if ( is_numeric( $booking_id ) ) { // FixIn: 8.1.2.8.
1400 + if ( ! wpbc_is_booking_approved( $booking_id ) ) {
1401 + do_action( 'wpbc_booking_approved', $booking_id, 1 ); // FixIn: 8.7.6.1.
1402 +
1403 + wpbc_send_email_approved( $booking_id, 1, $email_reason );
1404 + }
1405 + } else {
1406 + $booking_id_arr = explode( ',', $booking_id );
1407 + foreach ( $booking_id_arr as $bk_id ) {
1408 + if ( ! wpbc_is_booking_approved( $bk_id ) ) {
1409 + do_action( 'wpbc_booking_approved', $bk_id, 1 ); // FixIn: 8.7.6.1.
1410 + wpbc_send_email_approved( $bk_id, 1, $email_reason );
3517 1411 }
3518 -
3519 - return true;
3520 1412 }
3521 -
3522 -
3523 - /**
3524 - * Approve specific booking and send email about this.
3525 - *
3526 - * @param int $booking_id - ID of booking
3527 - * @param string $email_reason
3528 - */
3529 - function wpbc_auto_approve_booking( $booking_id , $email_reason = '' ) {
3530 -
3531 - $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers
3532 -
3533 - if ( is_numeric( $booking_id ) ) { //FixIn: 8.1.2.8
3534 - if ( ! wpbc_is_booking_approved( $booking_id ) ) {
3535 - do_action( 'wpbc_booking_approved', $booking_id, 1 ); //FixIn: 8.7.6.1
1413 + }
3536 1414
3537 - wpbc_send_email_approved( $booking_id, 1, $email_reason );
3538 - }
3539 - } else {
3540 - $booking_id_arr = explode( ',',$booking_id );
3541 - foreach ( $booking_id_arr as $bk_id ) {
3542 - if ( ! wpbc_is_booking_approved( $bk_id ) ) {
3543 - do_action( 'wpbc_booking_approved', $bk_id, 1 ); //FixIn: 8.7.6.1
3544 - wpbc_send_email_approved( $bk_id, 1, $email_reason );
3545 - }
3546 - }
3547 - }
3548 -
3549 - $db_result = wpbc_db__booking_approve( $booking_id );
3550 -
3551 - if ( false === $db_result ){
3552 -
3553 - wpbc_redirect( site_url() );
3554 - }
1415 + $db_result = wpbc_db__booking_approve( $booking_id );
1416 +
1417 + if ( false === $db_result ) {
1418 +
1419 + wpbc_redirect( site_url() );
1420 + }
1421 +}
1422 +
1423 +
1424 +/**
1425 + * Set as Pending specific booking and send email about this.
1426 + *
1427 + * @param int $booking_id - ID of booking
1428 + * @param string $denyreason
1429 + */
1430 +function wpbc_auto_pending_booking( $booking_id, $denyreason = '' ) {
1431 + // FixIn: 8.4.7.25.
1432 +
1433 + global $wpdb;
1434 +
1435 + $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers.
1436 +
1437 + if ( is_numeric( $booking_id ) ) { // FixIn: 8.1.2.8.
1438 + if ( wpbc_is_booking_approved( $booking_id ) ) {
1439 + wpbc_send_email_deny( $booking_id, 1, $denyreason );
3555 1440 }
3556 -
3557 -
3558 - /**
3559 - * Set as Pending specific booking and send email about this.
3560 - *
3561 - * @param int $booking_id - ID of booking
3562 - * @param string $denyreason
3563 - */
3564 - function wpbc_auto_pending_booking( $booking_id, $denyreason = '' ) { //FixIn: 8.4.7.25
3565 -
3566 - global $wpdb;
3567 -
3568 - $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers
3569 -
3570 - if ( is_numeric( $booking_id ) ) { //FixIn: 8.1.2.8
3571 - if ( wpbc_is_booking_approved( $booking_id ) ) {
3572 - wpbc_send_email_deny( $booking_id, 1, $denyreason );
3573 - }
3574 - } else {
3575 - $booking_id_arr = explode( ',',$booking_id );
3576 - foreach ( $booking_id_arr as $bk_id ) {
3577 - if ( wpbc_is_booking_approved( $bk_id ) ) {
3578 - wpbc_send_email_deny( $bk_id, 1, $denyreason );
3579 - }
3580 -
3581 - }
1441 + } else {
1442 + $booking_id_arr = explode( ',', $booking_id );
1443 + foreach ( $booking_id_arr as $bk_id ) {
1444 + if ( wpbc_is_booking_approved( $bk_id ) ) {
1445 + wpbc_send_email_deny( $bk_id, 1, $denyreason );
3582 1446 }
3583 -
3584 - $update_sql = "UPDATE {$wpdb->prefix}bookingdates SET approved = '0' WHERE booking_id IN ({$booking_id});";
3585 -
3586 - if ( false === $wpdb->query( $update_sql ) ){
3587 -
3588 - wpbc_redirect( site_url() );
3589 - }
3590 1447 }
3591 -
3592 -
3593 - /**
3594 - * Cancel (move to Trash) specific booking.
3595 - *
3596 - * @param int $booking_id - ID of booking
3597 - * @param string $email_reason - reason of cancellation
3598 - */
3599 - function wpbc_auto_cancel_booking( $booking_id , $email_reason = '' ) { //FixIn: 8.4.7.25
3600 -
3601 - global $wpdb;
3602 -
3603 - $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers
3604 -
3605 - if ( empty( $email_reason ) ) { //FixIn: 8.4.7.25
3606 - // Get the reason of cancellation.
3607 - $email_reason = __( 'Payment rejected', 'booking' );
3608 - $auto_cancel_pending_unpaid_bk_is_send_email = get_bk_option( 'booking_auto_cancel_pending_unpaid_bk_is_send_email' );
3609 - if ( $auto_cancel_pending_unpaid_bk_is_send_email == 'On' ) {
3610 - $email_reason = get_bk_option( 'booking_auto_cancel_pending_unpaid_bk_email_reason' );
3611 - }
3612 - }
3613 - // Send decline emails
3614 - wpbc_send_email_trash( $booking_id, 1, $email_reason );
3615 -
3616 - if ( false === $wpdb->query( "UPDATE {$wpdb->prefix}booking AS bk SET bk.trash = 1 WHERE booking_id IN ({$booking_id})" ) ){
3617 -
3618 - wpbc_redirect( site_url() );
3619 - }
1448 + }
1449 +
1450 + $update_sql = "UPDATE {$wpdb->prefix}bookingdates SET approved = '0' WHERE booking_id IN ({$booking_id});";
1451 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
1452 + if ( false === $wpdb->query( $update_sql ) ) {
1453 +
1454 + wpbc_redirect( site_url() );
1455 + }
1456 +}
1457 +
1458 +
1459 +/**
1460 + * Cancel (move to Trash) specific booking.
1461 + *
1462 + * @param int $booking_id - ID of booking
1463 + * @param string $email_reason - reason of cancellation
1464 + */
1465 +function wpbc_auto_cancel_booking( $booking_id, $email_reason = '' ) {
1466 + // FixIn: 8.4.7.25.
1467 +
1468 + global $wpdb;
1469 +
1470 + $booking_id = wpbc_clean_digit_or_csd( $booking_id ); // Check paramter if it number or comma separated list of numbers.
1471 +
1472 + if ( empty( $email_reason ) ) { // FixIn: 8.4.7.25.
1473 + // Get the reason of cancellation.
1474 + $email_reason = __( 'Payment rejected', 'booking' );
1475 + $auto_cancel_pending_unpaid_bk_is_send_email = get_bk_option( 'booking_auto_cancel_pending_unpaid_bk_is_send_email' );
1476 + if ( 'On' === $auto_cancel_pending_unpaid_bk_is_send_email ) {
1477 + $email_reason = get_bk_option( 'booking_auto_cancel_pending_unpaid_bk_email_reason' );
3620 1478 }
1479 + }
1480 + // Send decline emails.
1481 + wpbc_send_email_trash( $booking_id, 1, $email_reason );
1482 + // FixIn: 10.12.1.5.
1483 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
1484 + if ( false === $wpdb->query( "UPDATE {$wpdb->prefix}booking SET trash = 1 WHERE booking_id IN ({$booking_id})" ) ) {
3621 1485
1486 + wpbc_redirect( site_url() );
1487 + }
1488 +}
3622 1489
3623 - //FixIn: 9.9.0.43
3624 1490
1491 + // FixIn: 9.9.0.43.
1492 +
3625 1493 /**
3626 1494 * Auto approve booking and send email, after successful payment process
3627 1495 *
3628 1496 * It resolves issue in Booking Calendar MultiUser version for sending "regular email" to visitors, if was made booking for booking resource, that belong to regular user,
@@ -3632,9 +1500,9 @@
3632 1500 *
3633 1501 * @return void
3634 1502 */
3635 1503 function wpbc_auto_approve_booking__after_payment( $booking_id ) {
3636 - //-------------------------------------------------------------------------------------------------- //FixIn: 9.9.0.43
1504 + //-------------------------------------------------------------------------------------------------- // FixIn: 9.9.0.43.
3637 1505 $is_force_again = false;
3638 1506 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
3639 1507
3640 1508 list( $booking_hash, $booking_resource_id ) = wpbc_hash__get_booking_hash__resource_id( $booking_id );
@@ -3658,9 +1526,9 @@
3658 1526 // -------------------------------------------------------------------------------------------------
3659 1527
3660 1528 wpbc_auto_approve_booking( $booking_id );
3661 1529
3662 - if ( $is_force_again ) { //FixIn: 9.9.0.43
1530 + if ( $is_force_again ) { // FixIn: 9.9.0.43.
3663 1531 make_bk_action( 'make_force_using_this_user', - 999 ); // '-999' - This ID "by default" is the ID of super booking admin user
3664 1532 }
3665 1533 }
3666 1534
@@ -3675,9 +1543,9 @@
3675 1543 *
3676 1544 * @return void
3677 1545 */
3678 1546 function wpbc_auto_cancel_booking__after_payment( $booking_id ) {
3679 - //-------------------------------------------------------------------------------------------------- //FixIn: 9.9.0.43
1547 + //-------------------------------------------------------------------------------------------------- // FixIn: 9.9.0.43.
3680 1548 $is_force_again = false;
3681 1549 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
3682 1550
3683 1551 list( $booking_hash, $booking_resource_id ) = wpbc_hash__get_booking_hash__resource_id( $booking_id );
@@ -3701,9 +1569,9 @@
3701 1569 // -------------------------------------------------------------------------------------------------
3702 1570
3703 1571 wpbc_auto_cancel_booking( $booking_id );
3704 1572
3705 - if ( $is_force_again ) { //FixIn: 9.9.0.43
1573 + if ( $is_force_again ) { // FixIn: 9.9.0.43.
3706 1574 make_bk_action( 'make_force_using_this_user', - 999 ); // '-999' - This ID "by default" is the ID of super booking admin user
3707 1575 }
3708 1576 }
3709 1577 // </editor-fold>
@@ -3708,446 +1576,8 @@
3708 1576 }
3709 1577 // </editor-fold>
3710 1578
3711 1579
3712 - // <editor-fold defaultstate="collapsed" desc=" == REGION CITIES LIST - Support functions Timezone in .ICS & Google Calendar == " >
3713 -
3714 - /**
3715 - * Get list of cities for timezone usage in format like: $city["Europe"]["Kiev"] = "Kiev";
3716 - *
3717 - * @return array|array[]
3718 - */
3719 - function wpbc_get_booking_region_cities_list(){ //FixIn: 8.9.4.9
3720 -
3721 - $city = array(
3722 - 'Africa' => array()
3723 - , 'America' => array()
3724 - , 'Antarctica' => array()
3725 - , 'Arctic' => array()
3726 - , 'Asia' => array()
3727 - , 'Atlantic' => array()
3728 - , 'Australia' => array()
3729 - , 'Europe' => array()
3730 - , 'Indian' => array()
3731 - , 'Pacific' => array()
3732 - );
3733 - $city["Africa"]["Abidjan"] = "Abidjan";
3734 - $city["Africa"]["Accra"] = "Accra";
3735 - $city["Africa"]["Addis_Ababa"] = "Addis Ababa";
3736 - $city["Africa"]["Algiers"] = "Algiers";
3737 - $city["Africa"]["Asmara"] = "Asmara";
3738 - $city["Africa"]["Bamako"] = "Bamako";
3739 - $city["Africa"]["Bangui"] = "Bangui";
3740 - $city["Africa"]["Banjul"] = "Banjul";
3741 - $city["Africa"]["Bissau"] = "Bissau";
3742 - $city["Africa"]["Blantyre"] = "Blantyre";
3743 - $city["Africa"]["Brazzaville"] = "Brazzaville";
3744 - $city["Africa"]["Bujumbura"] = "Bujumbura";
3745 - $city["Africa"]["Cairo"] = "Cairo";
3746 - $city["Africa"]["Casablanca"] = "Casablanca";
3747 - $city["Africa"]["Ceuta"] = "Ceuta";
3748 - $city["Africa"]["Conakry"] = "Conakry";
3749 - $city["Africa"]["Dakar"] = "Dakar";
3750 - $city["Africa"]["Dar_es_Salaam"] = "Dar es Salaam";
3751 - $city["Africa"]["Djibouti"] = "Djibouti";
3752 - $city["Africa"]["Douala"] = "Douala";
3753 - $city["Africa"]["El_Aaiun"] = "El Aaiun";
3754 - $city["Africa"]["Freetown"] = "Freetown";
3755 - $city["Africa"]["Gaborone"] = "Gaborone";
3756 - $city["Africa"]["Harare"] = "Harare";
3757 - $city["Africa"]["Johannesburg"] = "Johannesburg";
3758 - $city["Africa"]["Kampala"] = "Kampala";
3759 - $city["Africa"]["Khartoum"] = "Khartoum";
3760 - $city["Africa"]["Kigali"] = "Kigali";
3761 - $city["Africa"]["Kinshasa"] = "Kinshasa";
3762 - $city["Africa"]["Lagos"] = "Lagos";
3763 - $city["Africa"]["Libreville"] = "Libreville";
3764 - $city["Africa"]["Lome"] = "Lome";
3765 - $city["Africa"]["Luanda"] = "Luanda";
3766 - $city["Africa"]["Lubumbashi"] = "Lubumbashi";
3767 - $city["Africa"]["Lusaka"] = "Lusaka";
3768 - $city["Africa"]["Malabo"] = "Malabo";
3769 - $city["Africa"]["Maputo"] = "Maputo";
3770 - $city["Africa"]["Maseru"] = "Maseru";
3771 - $city["Africa"]["Mbabane"] = "Mbabane";
3772 - $city["Africa"]["Mogadishu"] = "Mogadishu";
3773 - $city["Africa"]["Monrovia"] = "Monrovia";
3774 - $city["Africa"]["Nairobi"] = "Nairobi";
3775 - $city["Africa"]["Ndjamena"] = "Ndjamena";
3776 - $city["Africa"]["Niamey"] = "Niamey";
3777 - $city["Africa"]["Nouakchott"] = "Nouakchott";
3778 - $city["Africa"]["Ouagadougou"] = "Ouagadougou";
3779 - $city["Africa"]["Porto-Novo"] = "Porto-Novo";
3780 - $city["Africa"]["Sao_Tome"] = "Sao Tome";
3781 - $city["Africa"]["Tripoli"] = "Tripoli";
3782 - $city["Africa"]["Tunis"] = "Tunis";
3783 - $city["Africa"]["Windhoek"] = "Windhoek";
3784 -
3785 - $city["America"]["Adak"] = "Adak";
3786 - $city["America"]["Anchorage"] = "Anchorage";
3787 - $city["America"]["Anguilla"] = "Anguilla";
3788 - $city["America"]["Antigua"] = "Antigua";
3789 - $city["America"]["Araguaina"] = "Araguaina";
3790 - $city["America"]["Argentina/Buenos_Aires"] = "Argentina - Buenos Aires";
3791 - $city["America"]["Argentina/Catamarca"] = "Argentina - Catamarca";
3792 - $city["America"]["Argentina/Cordoba"] = "Argentina - Cordoba";
3793 - $city["America"]["Argentina/Jujuy"] = "Argentina - Jujuy";
3794 - $city["America"]["Argentina/La_Rioja"] = "Argentina - La Rioja";
3795 - $city["America"]["Argentina/Mendoza"] = "Argentina - Mendoza";
3796 - $city["America"]["Argentina/Rio_Gallegos"] = "Argentina - Rio Gallegos";
3797 - $city["America"]["Argentina/Salta"] = "Argentina - Salta";
3798 - $city["America"]["Argentina/San_Juan"] = "Argentina - San Juan";
3799 - $city["America"]["Argentina/San_Luis"] = "Argentina - San Luis";
3800 - $city["America"]["Argentina/Tucuman"] = "Argentina - Tucuman";
3801 - $city["America"]["Argentina/Ushuaia"] = "Argentina - Ushuaia";
3802 - $city["America"]["Aruba"] = "Aruba";
3803 - $city["America"]["Asuncion"] = "Asuncion";
3804 - $city["America"]["Atikokan"] = "Atikokan";
3805 - $city["America"]["Bahia"] = "Bahia";
3806 - $city["America"]["Barbados"] = "Barbados";
3807 - $city["America"]["Belem"] = "Belem";
3808 - $city["America"]["Belize"] = "Belize";
3809 - $city["America"]["Blanc-Sablon"] = "Blanc-Sablon";
3810 - $city["America"]["Boa_Vista"] = "Boa Vista";
3811 - $city["America"]["Bogota"] = "Bogota";
3812 - $city["America"]["Boise"] = "Boise";
3813 - $city["America"]["Cambridge_Bay"] = "Cambridge Bay";
3814 - $city["America"]["Campo_Grande"] = "Campo Grande";
3815 - $city["America"]["Cancun"] = "Cancun";
3816 - $city["America"]["Caracas"] = "Caracas";
3817 - $city["America"]["Cayenne"] = "Cayenne";
3818 - $city["America"]["Cayman"] = "Cayman";
3819 - $city["America"]["Chicago"] = "Chicago";
3820 - $city["America"]["Chihuahua"] = "Chihuahua";
3821 - $city["America"]["Costa_Rica"] = "Costa Rica";
3822 - $city["America"]["Cuiaba"] = "Cuiaba";
3823 - $city["America"]["Curacao"] = "Curacao";
3824 - $city["America"]["Danmarkshavn"] = "Danmarkshavn";
3825 - $city["America"]["Dawson"] = "Dawson";
3826 - $city["America"]["Dawson_Creek"] = "Dawson Creek";
3827 - $city["America"]["Denver"] = "Denver";
3828 - $city["America"]["Detroit"] = "Detroit";
3829 - $city["America"]["Dominica"] = "Dominica";
3830 - $city["America"]["Edmonton"] = "Edmonton";
3831 - $city["America"]["Eirunepe"] = "Eirunepe";
3832 - $city["America"]["El_Salvador"] = "El Salvador";
3833 - $city["America"]["Fortaleza"] = "Fortaleza";
3834 - $city["America"]["Glace_Bay"] = "Glace Bay";
3835 - $city["America"]["Godthab"] = "Godthab";
3836 - $city["America"]["Goose_Bay"] = "Goose Bay";
3837 - $city["America"]["Grand_Turk"] = "Grand Turk";
3838 - $city["America"]["Grenada"] = "Grenada";
3839 - $city["America"]["Guadeloupe"] = "Guadeloupe";
3840 - $city["America"]["Guatemala"] = "Guatemala";
3841 - $city["America"]["Guayaquil"] = "Guayaquil";
3842 - $city["America"]["Guyana"] = "Guyana";
3843 - $city["America"]["Halifax"] = "Halifax";
3844 - $city["America"]["Havana"] = "Havana";
3845 - $city["America"]["Hermosillo"] = "Hermosillo";
3846 - $city["America"]["Indiana/Indianapolis"] = "Indiana - Indianapolis";
3847 - $city["America"]["Indiana/Knox"] = "Indiana - Knox";
3848 - $city["America"]["Indiana/Marengo"] = "Indiana - Marengo";
3849 - $city["America"]["Indiana/Petersburg"] = "Indiana - Petersburg";
3850 - $city["America"]["Indiana/Tell_City"] = "Indiana - Tell City";
3851 - $city["America"]["Indiana/Vevay"] = "Indiana - Vevay";
3852 - $city["America"]["Indiana/Vincennes"] = "Indiana - Vincennes";
3853 - $city["America"]["Indiana/Winamac"] = "Indiana - Winamac";
3854 - $city["America"]["Inuvik"] = "Inuvik";
3855 - $city["America"]["Iqaluit"] = "Iqaluit";
3856 - $city["America"]["Jamaica"] = "Jamaica";
3857 - $city["America"]["Juneau"] = "Juneau";
3858 - $city["America"]["Kentucky/Louisville"] = "Kentucky - Louisville";
3859 - $city["America"]["Kentucky/Monticello"] = "Kentucky - Monticello";
3860 - $city["America"]["La_Paz"] = "La Paz";
3861 - $city["America"]["Lima"] = "Lima";
3862 - $city["America"]["Los_Angeles"] = "Los Angeles";
3863 - $city["America"]["Maceio"] = "Maceio";
3864 - $city["America"]["Managua"] = "Managua";
3865 - $city["America"]["Manaus"] = "Manaus";
3866 - $city["America"]["Marigot"] = "Marigot";
3867 - $city["America"]["Martinique"] = "Martinique";
3868 - $city["America"]["Mazatlan"] = "Mazatlan";
3869 - $city["America"]["Menominee"] = "Menominee";
3870 - $city["America"]["Merida"] = "Merida";
3871 - $city["America"]["Mexico_City"] = "Mexico City";
3872 - $city["America"]["Miquelon"] = "Miquelon";
3873 - $city["America"]["Moncton"] = "Moncton";
3874 - $city["America"]["Monterrey"] = "Monterrey";
3875 - $city["America"]["Montevideo"] = "Montevideo";
3876 - $city["America"]["Montreal"] = "Montreal";
3877 - $city["America"]["Montserrat"] = "Montserrat";
3878 - $city["America"]["Nassau"] = "Nassau";
3879 - $city["America"]["New_York"] = "New York";
3880 - $city["America"]["Nipigon"] = "Nipigon";
3881 - $city["America"]["Nome"] = "Nome";
3882 - $city["America"]["Noronha"] = "Noronha";
3883 - $city["America"]["North_Dakota/Center"] = "North Dakota - Center";
3884 - $city["America"]["North_Dakota/New_Salem"] = "North Dakota - New Salem";
3885 - $city["America"]["Panama"] = "Panama";
3886 - $city["America"]["Pangnirtung"] = "Pangnirtung";
3887 - $city["America"]["Paramaribo"] = "Paramaribo";
3888 - $city["America"]["Phoenix"] = "Phoenix";
3889 - $city["America"]["Port-au-Prince"] = "Port-au-Prince";
3890 - $city["America"]["Port_of_Spain"] = "Port of Spain";
3891 - $city["America"]["Porto_Velho"] = "Porto Velho";
3892 - $city["America"]["Puerto_Rico"] = "Puerto Rico";
3893 - $city["America"]["Rainy_River"] = "Rainy River";
3894 - $city["America"]["Rankin_Inlet"] = "Rankin Inlet";
3895 - $city["America"]["Recife"] = "Recife";
3896 - $city["America"]["Regina"] = "Regina";
3897 - $city["America"]["Resolute"] = "Resolute";
3898 - $city["America"]["Rio_Branco"] = "Rio Branco";
3899 - $city["America"]["Santarem"] = "Santarem";
3900 - $city["America"]["Santiago"] = "Santiago";
3901 - $city["America"]["Santo_Domingo"] = "Santo Domingo";
3902 - $city["America"]["Sao_Paulo"] = "Sao Paulo";
3903 - $city["America"]["Scoresbysund"] = "Scoresbysund";
3904 - $city["America"]["Shiprock"] = "Shiprock";
3905 - $city["America"]["St_Barthelemy"] = "St Barthelemy";
3906 - $city["America"]["St_Johns"] = "St Johns";
3907 - $city["America"]["St_Kitts"] = "St Kitts";
3908 - $city["America"]["St_Lucia"] = "St Lucia";
3909 - $city["America"]["St_Thomas"] = "St Thomas";
3910 - $city["America"]["St_Vincent"] = "St Vincent";
3911 - $city["America"]["Swift_Current"] = "Swift Current";
3912 - $city["America"]["Tegucigalpa"] = "Tegucigalpa";
3913 - $city["America"]["Thule"] = "Thule";
3914 - $city["America"]["Thunder_Bay"] = "Thunder Bay";
3915 - $city["America"]["Tijuana"] = "Tijuana";
3916 - $city["America"]["Toronto"] = "Toronto";
3917 - $city["America"]["Tortola"] = "Tortola";
3918 - $city["America"]["Vancouver"] = "Vancouver";
3919 - $city["America"]["Whitehorse"] = "Whitehorse";
3920 - $city["America"]["Winnipeg"] = "Winnipeg";
3921 - $city["America"]["Yakutat"] = "Yakutat";
3922 - $city["America"]["Yellowknife"] = "Yellowknife";
3923 -
3924 - $city["Antarctica"]["Casey"] = "Casey";
3925 - $city["Antarctica"]["Davis"] = "Davis";
3926 - $city["Antarctica"]["DumontDUrville"] = "DumontDUrville";
3927 - $city["Antarctica"]["Mawson"] = "Mawson";
3928 - $city["Antarctica"]["McMurdo"] = "McMurdo";
3929 - $city["Antarctica"]["Palmer"] = "Palmer";
3930 - $city["Antarctica"]["Rothera"] = "Rothera";
3931 - $city["Antarctica"]["South_Pole"] = "South Pole";
3932 - $city["Antarctica"]["Syowa"] = "Syowa";
3933 - $city["Antarctica"]["Vostok"] = "Vostok";
3934 -
3935 - $city["Arctic"]["Longyearbyen"] = "Longyearbyen";
3936 -
3937 - $city["Asia"]["Aden"] = "Aden";
3938 - $city["Asia"]["Almaty"] = "Almaty";
3939 - $city["Asia"]["Amman"] = "Amman";
3940 - $city["Asia"]["Anadyr"] = "Anadyr";
3941 - $city["Asia"]["Aqtau"] = "Aqtau";
3942 - $city["Asia"]["Aqtobe"] = "Aqtobe";
3943 - $city["Asia"]["Ashgabat"] = "Ashgabat";
3944 - $city["Asia"]["Baghdad"] = "Baghdad";
3945 - $city["Asia"]["Bahrain"] = "Bahrain";
3946 - $city["Asia"]["Baku"] = "Baku";
3947 - $city["Asia"]["Bangkok"] = "Bangkok";
3948 - $city["Asia"]["Beirut"] = "Beirut";
3949 - $city["Asia"]["Bishkek"] = "Bishkek";
3950 - $city["Asia"]["Brunei"] = "Brunei";
3951 - $city["Asia"]["Choibalsan"] = "Choibalsan";
3952 - $city["Asia"]["Chongqing"] = "Chongqing";
3953 - $city["Asia"]["Colombo"] = "Colombo";
3954 - $city["Asia"]["Damascus"] = "Damascus";
3955 - $city["Asia"]["Dhaka"] = "Dhaka";
3956 - $city["Asia"]["Dili"] = "Dili";
3957 - $city["Asia"]["Dubai"] = "Dubai";
3958 - $city["Asia"]["Dushanbe"] = "Dushanbe";
3959 - $city["Asia"]["Gaza"] = "Gaza";
3960 - $city["Asia"]["Harbin"] = "Harbin";
3961 - $city["Asia"]["Ho_Chi_Minh"] = "Ho Chi Minh";
3962 - $city["Asia"]["Hong_Kong"] = "Hong Kong";
3963 - $city["Asia"]["Hovd"] = "Hovd";
3964 - $city["Asia"]["Irkutsk"] = "Irkutsk";
3965 - $city["Asia"]["Jakarta"] = "Jakarta";
3966 - $city["Asia"]["Jayapura"] = "Jayapura";
3967 - $city["Asia"]["Jerusalem"] = "Jerusalem";
3968 - $city["Asia"]["Kabul"] = "Kabul";
3969 - $city["Asia"]["Kamchatka"] = "Kamchatka";
3970 - $city["Asia"]["Karachi"] = "Karachi";
3971 - $city["Asia"]["Kashgar"] = "Kashgar";
3972 - $city["Asia"]["Kathmandu"] = "Kathmandu";
3973 - $city["Asia"]["Kolkata"] = "Kolkata";
3974 - $city["Asia"]["Krasnoyarsk"] = "Krasnoyarsk";
3975 - $city["Asia"]["Kuala_Lumpur"] = "Kuala Lumpur";
3976 - $city["Asia"]["Kuching"] = "Kuching";
3977 - $city["Asia"]["Kuwait"] = "Kuwait";
3978 - $city["Asia"]["Macau"] = "Macau";
3979 - $city["Asia"]["Magadan"] = "Magadan";
3980 - $city["Asia"]["Makassar"] = "Makassar";
3981 - $city["Asia"]["Manila"] = "Manila";
3982 - $city["Asia"]["Muscat"] = "Muscat";
3983 - $city["Asia"]["Nicosia"] = "Nicosia";
3984 - $city["Asia"]["Novosibirsk"] = "Novosibirsk";
3985 - $city["Asia"]["Omsk"] = "Omsk";
3986 - $city["Asia"]["Oral"] = "Oral";
3987 - $city["Asia"]["Phnom_Penh"] = "Phnom Penh";
3988 - $city["Asia"]["Pontianak"] = "Pontianak";
3989 - $city["Asia"]["Pyongyang"] = "Pyongyang";
3990 - $city["Asia"]["Qatar"] = "Qatar";
3991 - $city["Asia"]["Qyzylorda"] = "Qyzylorda";
3992 - $city["Asia"]["Rangoon"] = "Rangoon";
3993 - $city["Asia"]["Riyadh"] = "Riyadh";
3994 - $city["Asia"]["Sakhalin"] = "Sakhalin";
3995 - $city["Asia"]["Samarkand"] = "Samarkand";
3996 - $city["Asia"]["Seoul"] = "Seoul";
3997 - $city["Asia"]["Shanghai"] = "Shanghai";
3998 - $city["Asia"]["Singapore"] = "Singapore";
3999 - $city["Asia"]["Taipei"] = "Taipei";
4000 - $city["Asia"]["Tashkent"] = "Tashkent";
4001 - $city["Asia"]["Tbilisi"] = "Tbilisi";
4002 - $city["Asia"]["Tehran"] = "Tehran";
4003 - $city["Asia"]["Thimphu"] = "Thimphu";
4004 - $city["Asia"]["Tokyo"] = "Tokyo";
4005 - $city["Asia"]["Ulaanbaatar"] = "Ulaanbaatar";
4006 - $city["Asia"]["Urumqi"] = "Urumqi";
4007 - $city["Asia"]["Vientiane"] = "Vientiane";
4008 - $city["Asia"]["Vladivostok"] = "Vladivostok";
4009 - $city["Asia"]["Yakutsk"] = "Yakutsk";
4010 - $city["Asia"]["Yekaterinburg"] = "Yekaterinburg";
4011 - $city["Asia"]["Yerevan"] = "Yerevan";
4012 -
4013 - $city["Atlantic"]["Azores"] = "Azores";
4014 - $city["Atlantic"]["Bermuda"] = "Bermuda";
4015 - $city["Atlantic"]["Canary"] = "Canary";
4016 - $city["Atlantic"]["Cape_Verde"] = "Cape Verde";
4017 - $city["Atlantic"]["Faroe"] = "Faroe";
4018 - $city["Atlantic"]["Madeira"] = "Madeira";
4019 - $city["Atlantic"]["Reykjavik"] = "Reykjavik";
4020 - $city["Atlantic"]["South_Georgia"] = "South Georgia";
4021 - $city["Atlantic"]["Stanley"] = "Stanley";
4022 - $city["Atlantic"]["St_Helena"] = "St Helena";
4023 -
4024 - $city["Australia"]["Adelaide"] = "Adelaide";
4025 - $city["Australia"]["Brisbane"] = "Brisbane";
4026 - $city["Australia"]["Broken_Hill"] = "Broken Hill";
4027 - $city["Australia"]["Currie"] = "Currie";
4028 - $city["Australia"]["Darwin"] = "Darwin";
4029 - $city["Australia"]["Eucla"] = "Eucla";
4030 - $city["Australia"]["Hobart"] = "Hobart";
4031 - $city["Australia"]["Lindeman"] = "Lindeman";
4032 - $city["Australia"]["Lord_Howe"] = "Lord Howe";
4033 - $city["Australia"]["Melbourne"] = "Melbourne";
4034 - $city["Australia"]["Perth"] = "Perth";
4035 - $city["Australia"]["Sydney"] = "Sydney";
4036 -
4037 - $city["Europe"]["Amsterdam"] = "Amsterdam";
4038 - $city["Europe"]["Andorra"] = "Andorra";
4039 - $city["Europe"]["Athens"] = "Athens";
4040 - $city["Europe"]["Belgrade"] = "Belgrade";
4041 - $city["Europe"]["Berlin"] = "Berlin";
4042 - $city["Europe"]["Bratislava"] = "Bratislava";
4043 - $city["Europe"]["Brussels"] = "Brussels";
4044 - $city["Europe"]["Bucharest"] = "Bucharest";
4045 - $city["Europe"]["Budapest"] = "Budapest";
4046 - $city["Europe"]["Chisinau"] = "Chisinau";
4047 - $city["Europe"]["Copenhagen"] = "Copenhagen";
4048 - $city["Europe"]["Dublin"] = "Dublin";
4049 - $city["Europe"]["Gibraltar"] = "Gibraltar";
4050 - $city["Europe"]["Guernsey"] = "Guernsey";
4051 - $city["Europe"]["Helsinki"] = "Helsinki";
4052 - $city["Europe"]["Isle_of_Man"] = "Isle of Man";
4053 - $city["Europe"]["Istanbul"] = "Istanbul";
4054 - $city["Europe"]["Jersey"] = "Jersey";
4055 - $city["Europe"]["Kaliningrad"] = "Kaliningrad";
4056 - $city["Europe"]["Kiev"] = "Kiev";
4057 - $city["Europe"]["Lisbon"] = "Lisbon";
4058 - $city["Europe"]["Ljubljana"] = "Ljubljana";
4059 - $city["Europe"]["London"] = "London";
4060 - $city["Europe"]["Luxembourg"] = "Luxembourg";
4061 - $city["Europe"]["Madrid"] = "Madrid";
4062 - $city["Europe"]["Malta"] = "Malta";
4063 - $city["Europe"]["Mariehamn"] = "Mariehamn";
4064 - $city["Europe"]["Minsk"] = "Minsk";
4065 - $city["Europe"]["Monaco"] = "Monaco";
4066 - $city["Europe"]["Moscow"] = "Moscow";
4067 - $city["Europe"]["Oslo"] = "Oslo";
4068 - $city["Europe"]["Paris"] = "Paris";
4069 - $city["Europe"]["Podgorica"] = "Podgorica";
4070 - $city["Europe"]["Prague"] = "Prague";
4071 - $city["Europe"]["Riga"] = "Riga";
4072 - $city["Europe"]["Rome"] = "Rome";
4073 - $city["Europe"]["Samara"] = "Samara";
4074 - $city["Europe"]["San_Marino"] = "San Marino";
4075 - $city["Europe"]["Sarajevo"] = "Sarajevo";
4076 - $city["Europe"]["Simferopol"] = "Simferopol";
4077 - $city["Europe"]["Skopje"] = "Skopje";
4078 - $city["Europe"]["Sofia"] = "Sofia";
4079 - $city["Europe"]["Stockholm"] = "Stockholm";
4080 - $city["Europe"]["Tallinn"] = "Tallinn";
4081 - $city["Europe"]["Tirane"] = "Tirane";
4082 - $city["Europe"]["Uzhgorod"] = "Uzhgorod";
4083 - $city["Europe"]["Vaduz"] = "Vaduz";
4084 - $city["Europe"]["Vatican"] = "Vatican";
4085 - $city["Europe"]["Vienna"] = "Vienna";
4086 - $city["Europe"]["Vilnius"] = "Vilnius";
4087 - $city["Europe"]["Volgograd"] = "Volgograd";
4088 - $city["Europe"]["Warsaw"] = "Warsaw";
4089 - $city["Europe"]["Zagreb"] = "Zagreb";
4090 - $city["Europe"]["Zaporozhye"] = "Zaporozhye";
4091 - $city["Europe"]["Zurich"] = "Zurich";
4092 -
4093 - $city["Indian"]["Antananarivo"] = "Antananarivo";
4094 - $city["Indian"]["Chagos"] = "Chagos";
4095 - $city["Indian"]["Christmas"] = "Christmas";
4096 - $city["Indian"]["Cocos"] = "Cocos";
4097 - $city["Indian"]["Comoro"] = "Comoro";
4098 - $city["Indian"]["Kerguelen"] = "Kerguelen";
4099 - $city["Indian"]["Mahe"] = "Mahe";
4100 - $city["Indian"]["Maldives"] = "Maldives";
4101 - $city["Indian"]["Mauritius"] = "Mauritius";
4102 - $city["Indian"]["Mayotte"] = "Mayotte";
4103 - $city["Indian"]["Reunion"] = "Reunion";
4104 -
4105 - $city["Pacific"]["Apia"] = "Apia";
4106 - $city["Pacific"]["Auckland"] = "Auckland";
4107 - $city["Pacific"]["Chatham"] = "Chatham";
4108 - $city["Pacific"]["Easter"] = "Easter";
4109 - $city["Pacific"]["Efate"] = "Efate";
4110 - $city["Pacific"]["Enderbury"] = "Enderbury";
4111 - $city["Pacific"]["Fakaofo"] = "Fakaofo";
4112 - $city["Pacific"]["Fiji"] = "Fiji";
4113 - $city["Pacific"]["Funafuti"] = "Funafuti";
4114 - $city["Pacific"]["Galapagos"] = "Galapagos";
4115 - $city["Pacific"]["Gambier"] = "Gambier";
4116 - $city["Pacific"]["Guadalcanal"] = "Guadalcanal";
4117 - $city["Pacific"]["Guam"] = "Guam";
4118 - $city["Pacific"]["Honolulu"] = "Honolulu";
4119 - $city["Pacific"]["Johnston"] = "Johnston";
4120 - $city["Pacific"]["Kiritimati"] = "Kiritimati";
4121 - $city["Pacific"]["Kosrae"] = "Kosrae";
4122 - $city["Pacific"]["Kwajalein"] = "Kwajalein";
4123 - $city["Pacific"]["Majuro"] = "Majuro";
4124 - $city["Pacific"]["Marquesas"] = "Marquesas";
4125 - $city["Pacific"]["Midway"] = "Midway";
4126 - $city["Pacific"]["Nauru"] = "Nauru";
4127 - $city["Pacific"]["Niue"] = "Niue";
4128 - $city["Pacific"]["Norfolk"] = "Norfolk";
4129 - $city["Pacific"]["Noumea"] = "Noumea";
4130 - $city["Pacific"]["Pago_Pago"] = "Pago Pago";
4131 - $city["Pacific"]["Palau"] = "Palau";
4132 - $city["Pacific"]["Pitcairn"] = "Pitcairn";
4133 - $city["Pacific"]["Ponape"] = "Ponape";
4134 - $city["Pacific"]["Port_Moresby"] = "Port Moresby";
4135 - $city["Pacific"]["Rarotonga"] = "Rarotonga";
4136 - $city["Pacific"]["Saipan"] = "Saipan";
4137 - $city["Pacific"]["Tahiti"] = "Tahiti";
4138 - $city["Pacific"]["Tarawa"] = "Tarawa";
4139 - $city["Pacific"]["Tongatapu"] = "Tongatapu";
4140 - $city["Pacific"]["Truk"] = "Truk";
4141 - $city["Pacific"]["Wake"] = "Wake";
4142 - $city["Pacific"]["Wallis"] = "Wallis";
4143 -
4144 - return $city;
4145 - }
4146 -
4147 - // </editor-fold>
4148 -
4149 -
4150 1580 // <editor-fold defaultstate="collapsed" desc=" == Logs for Notes / remarks == " >
4151 1581
4152 1582 /**
4153 1583 * Add Log info to Notes of bookings
@@ -4165,9 +1595,9 @@
4165 1595
4166 1596 $is_append = true;
4167 1597 foreach ( $booking_id_arr as $booking_id ) {
4168 1598 $date_time = date_i18n( '[Y-m-d H:i] ' );
4169 - make_bk_action('wpdev_make_update_of_remark' , $booking_id , $date_time . $message , $is_append ); //FixIn: 9.1.2.14
1599 + make_bk_action('wpdev_make_update_of_remark' , $booking_id , $date_time . $message , $is_append ); // FixIn: 9.1.2.14.
4170 1600 }
4171 1601 }
4172 1602
4173 1603 // </editor-fold>
@@ -4183,15 +1613,12 @@
4183 1613 * @return false|string
4184 1614 */
4185 1615 function wpbc_get_request_url_path(){
4186 1616
4187 - if ( function_exists( 'wp_parse_url' ) ) {
4188 - $my_parsed_url = wp_parse_url( $_SERVER['REQUEST_URI'] );
4189 - } else {
4190 - $my_parsed_url = @parse_url( $_SERVER['REQUEST_URI'] );
4191 - }
1617 + $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 */
1618 + $my_parsed_url = wp_parse_url( $server_request_uri );
4192 1619
4193 - if ( false === $my_parsed_url ) { // seriously malformed URLs, parse_url() may return FALSE.
1620 + if ( false === $my_parsed_url ) { // seriously malformed URLs, wp_parse_url() may return FALSE.
4194 1621 return false;
4195 1622 }
4196 1623
4197 1624 $my_parsed_url_path = trim( $my_parsed_url['path'] );
@@ -4197,16 +1624,16 @@
4197 1624 $my_parsed_url_path = trim( $my_parsed_url['path'] );
4198 1625 $my_parsed_url_path = trim( $my_parsed_url_path, '/' );
4199 1626
4200 1627
4201 - // Check internal sub folder of WP, like http://server.com/my-website/[ ... LINK ...] //FixIn: 2.0.5.4
1628 + // Check internal sub folder of WP, like http://server.com/my-website/[ ... LINK ...] // FixIn: 2.0.5.4.
4202 1629 if ( function_exists( 'wp_parse_url' ) ) {
4203 1630 $wp_home_server_url = wp_parse_url( home_url() );
4204 1631 } else {
4205 - $wp_home_server_url = @parse_url( home_url() );
1632 + $wp_home_server_url = @wp_parse_url( home_url() );
4206 1633 }
4207 1634
4208 - if ( ( false !== $wp_home_server_url ) && ( ! empty( $wp_home_server_url['path'] ) ) ) { // seriously malformed URLs, parse_url() may return FALSE.
1635 + if ( ( false !== $wp_home_server_url ) && ( ! empty( $wp_home_server_url['path'] ) ) ) { // seriously malformed URLs, wp_parse_url() may return FALSE.
4209 1636
4210 1637 $server_url_sufix = trim( $wp_home_server_url[ 'path' ] ); // [path] => /my-website
4211 1638 $server_url_sufix = trim( $server_url_sufix, '/' ); // my-website
4212 1639
@@ -4273,18 +1700,18 @@
4273 1700 * @return array
4274 1701 *
4275 1702 * Example:
4276 1703 *
4277 - * $php_performance = php_performance_START( 'emails_sending' , $php_performance );
1704 + * $php_performance = wpbc_php_performance_START( 'emails_sending' , $php_performance );
4278 1705 *
4279 1706 * ... some code here ...
4280 1707 *
4281 - * $php_performance = php_performance_END( 'emails_sending' , $php_performance );
1708 + * $php_performance = wpbc_php_performance_END( 'emails_sending' , $php_performance );
4282 1709 *
4283 1710 * echo 'Time of execution: ' . $php_performancep['emails_sending']
4284 1711 *
4285 1712 */
4286 - function php_performance_START( $name, $php_performance ) {
1713 + function wpbc_php_performance_START( $name, $php_performance ) {
4287 1714
4288 1715 if ( empty( $php_performance ) ) {
4289 1716 $php_performance = array();
4290 1717 }
@@ -4303,18 +1730,18 @@
4303 1730 * @return array
4304 1731 *
4305 1732 * Example:
4306 1733 *
4307 - * $php_performance = php_performance_START( 'emails_sending' , $php_performance );
1734 + * $php_performance = wpbc_php_performance_START( 'emails_sending' , $php_performance );
4308 1735 *
4309 1736 * ... some code here ...
4310 1737 *
4311 - * $php_performance = php_performance_END( 'emails_sending' , $php_performance );
1738 + * $php_performance = wpbc_php_performance_END( 'emails_sending' , $php_performance );
4312 1739 *
4313 1740 * echo 'Time of execution: ' . $php_performancep['emails_sending']
4314 1741 *
4315 1742 */
4316 - function php_performance_END( $name, $php_performance ) {
1743 + function wpbc_php_performance_END( $name, $php_performance ) {
4317 1744
4318 1745 if ( empty( $php_performance ) ) {
4319 1746 $php_performance = array();
4320 1747 }
@@ -4333,29 +1760,60 @@
4333 1760 * @param $limit_in_seconds_int
4334 1761 *
4335 1762 * @return void
4336 1763 */
4337 - function wpbc_set_limit_php( $limit_in_seconds_int = 300 ){
1764 + function wpbc_set_limit_php( $limit_in_seconds_int = 300 ) {
4338 1765
4339 - $is_win = ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) );
1766 + WPBC_Action_Scheduler_Compatibility::raise_memory_limit();
1767 + WPBC_Action_Scheduler_Compatibility::raise_time_limit( $limit_in_seconds_int );
1768 + }
4340 1769
4341 - // Windows does not have support for this timeout function
4342 - if ( ! $is_win ) {
4343 1770
4344 - $max = (int) ini_get( 'max_execution_time' );
1771 + // </editor-fold>
4345 1772
4346 - // If unlimited, or if set_time_limit is disabled, then skip.
4347 - if (
4348 - ( 0 !== $max )
4349 - && ( $limit_in_seconds_int > $max )
4350 - && ( function_exists( 'set_time_limit' ) )
4351 - && ( false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) )
4352 - && ( ! ini_get( 'safe_mode' ) )
4353 - ) {
4354 - @set_time_limit( $limit_in_seconds_int );
4355 - @ini_set( 'memory_limit', '512M' );
4356 - }
4357 - }
4358 - }
4359 1773
4360 1774
4361 - // </editor-fold>
1775 +/**
1776 + * Temp fix of styles for edit specific season filter or rate.
1777 + *
1778 + * @return void
1779 + */
1780 +function wpbc_add_css_to_hide_seasons() {
1781 +
1782 + // TODO: 2025-05-03 temp fix of view edit filter
1783 + ?>
1784 + <style tye="text/css">
1785 + .wpdvlp-sub-tabs,
1786 + #wpbc_dcoupons_table, #wpbc_discountcoupons,
1787 + #bulk-action-selector-bottom,
1788 + #toolbar_booking_resources,
1789 + #toolbar_seasonfilters,
1790 + #wpbc_seasonfilters,
1791 + #wpbc_booking_resource_table{
1792 + display: none !important;
1793 + }
1794 + .wpbc_round_white_panel {
1795 + background: #fff;
1796 + padding: 1px 20px 20px;
1797 + border-radius: 10px
1798 + }
1799 + .header_for_cost_object_edit {
1800 + font-size: 20px;
1801 + padding: 0 0 15px;
1802 + border-bottom: 2px solid #f2f2f2;
1803 + margin: 15px 0;
1804 + line-height: 1.5;
1805 + display: flex;
1806 + flex-flow: row nowrap;
1807 + justify-content: space-between;
1808 + align-items: flex-start;
1809 + }
1810 + .in_header_container_for_resource_title {
1811 + color: #5379aa;
1812 + margin-left: 0.3em;
1813 + }
1814 + .header_for_cost_object_edit__close i.wpbc_icn_close::before {
1815 + font-size: 22px;
1816 + }
1817 + </style>
1818 + <?php
1819 +}