PluginProbe
Booking Calendar / 11.5
Booking Calendar v11.5
11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 10.11.4 All 201 releases
booking / includes / _functions / admin_menu_url.php

admin_menu_url.php in Booking Calendar 11.5, at includes/_functions/admin_menu_url.php

752 lines 28.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Admin Menu Functions
6 * @category Functions
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2024-09-03
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17 // =====================================================================================================================
18 // == URL functions ==
19 // =====================================================================================================================
20
21 /**
22 * Get absolute URL to relative plugin path.
23 * Possibly to load minified version of file, if its exist
24 * @param string $path - path
25 * @return string
26 */
27 function wpbc_plugin_url( $path ) {
28
29 return trailingslashit( WPBC_PLUGIN_URL ) . ltrim( $path, '/\\' );
30
31 }
32
33 // Set URL from absolute to relative (starting from /)
34 function wpbc_set_relative_url( $url ){
35
36 $url = esc_url_raw($url);
37
38 $url_path = wp_parse_url($url, PHP_URL_PATH);
39 $url_path = ( empty($url_path) ? $url : $url_path );
40
41 $url = trim($url_path, '/');
42 return '/' . $url;
43 }
44
45 /**
46 * Get Relative URL
47 *
48 * @param $maybe_absolute_link
49 *
50 * @return string
51 */
52 function wpbc_make_link_relative( $maybe_absolute_link ) {
53
54 if ( $maybe_absolute_link == get_option( 'siteurl' ) ) {
55 $maybe_absolute_link = '/';
56 }
57
58 $maybe_absolute_link = '/' . trim( wp_make_link_relative( $maybe_absolute_link ), '/' );
59
60 return $maybe_absolute_link;
61 }
62
63 /**
64 * Get Absolute URL (check for languages)
65 *
66 * @param $maybe_relative_link
67 *
68 * @return string
69 */
70 function wpbc_make_link_absolute( $maybe_relative_link ){
71
72 if ( ( $maybe_relative_link != home_url() ) && ( strpos( $maybe_relative_link, 'http' ) !== 0 ) ) {
73
74 $maybe_relative_link = wpbc_lang( $maybe_relative_link ); // FixIn: 8.4.5.1.
75
76 $maybe_relative_link = home_url() . '/' . trim( wp_make_link_relative( $maybe_relative_link ), '/' ); // FixIn: 7.0.1.20.
77 }
78
79 return esc_js( $maybe_relative_link );
80 }
81
82 /**
83 * Redirect browser to a specific page
84 *
85 * @param string $url - URL of page to redirect
86 */
87 function wpbc_redirect( $url ) {
88
89 $url = wpbc_make_link_absolute( $url );
90
91 $url = html_entity_decode( esc_url( $url ) );
92
93 echo '<script type="text/javascript">';
94 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
95 echo 'window.location.href="' . $url . '";';
96 echo '</script>';
97 echo '<noscript>';
98 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
99 echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
100 echo '</noscript>';
101 }
102
103
104 // =====================================================================================================================
105 // == Admin Menu Pages and URLs ==
106 // =====================================================================================================================
107
108 /**
109 * Check if we edit or create a new page in WordPress ?
110 * @return bool
111 */
112 function wpbc_is_on_edit_page() {
113
114 // FixIn: 9.9.0.39.
115
116 // Elementor.
117 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
118 if ( ( ! empty( $_REQUEST['action'] ) ) && ( ( 'elementor' === $_REQUEST['action'] ) || ( 'elementor_ajax' === $_REQUEST['action'] ) ) ) {
119 return false;
120 }
121
122 if ( ( ! empty( $GLOBALS['pagenow'] ) ) && ( is_admin() ) ) {
123 if (
124 ( 'post.php' === $GLOBALS['pagenow'] ) // Edit - Post / Page.
125 || ( 'post-new.php' === $GLOBALS['pagenow'] ) // Add New - Post / Page.
126 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
127 // || ( ( 'admin-ajax.php' === $GLOBALS['pagenow'] ) && ( ! empty( $_REQUEST['action'] ) ) && ( 'elementor_ajax' === $_REQUEST['action'] ) ) // Elementor Edit page - Ajax.
128 ) {
129 return true;
130 }
131 }
132
133 return false;
134 }
135
136 /**
137 * Get URL to specific Admin Menu page
138 *
139 * @param string $menu_type - { booking | add | resources | settings }
140 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
141 * @param boolean $is_old - { default: true }
142 * @return string - URL to menu
143 */
144 function wpbc_get_menu_url( $menu_type, $is_absolute_url = true, $is_old = true) {
145
146 $is_old = false;
147
148 switch ( $menu_type) {
149
150 case 'booking': // Bookings.
151 case 'bookings':
152 case 'booking-listing':
153 case 'bookings-listing':
154 case 'listing':
155 case 'overview':
156 case 'calendar-overview':
157 case 'timeline':
158 $link = 'wpbc';
159 break;
160
161 case 'add': // Add New Booking.
162 case 'add-bookings':
163 case 'add-booking':
164 case 'new':
165 case 'new-bookings':
166 case 'new-booking':
167 $link = 'wpbc&tab=add-booking';
168 break;
169
170 case 'availability':
171 $link = 'wpbc-availability';
172 break;
173
174 case 'price':
175 $link = 'wpbc-prices';
176 break;
177
178 case 'resources': // Resources.
179 case 'booking-resources':
180 $link = 'wpbc-resources';
181 break;
182
183 case 'settings': // Settings.
184 case 'options':
185 $link = 'wpbc-settings';
186 break;
187
188 case 'setup': // Setup.
189 $link = 'wpbc-setup';
190 break;
191
192 default: // Bookings.
193 $link = 'wpbc';
194 break;
195 }
196
197 if ( $is_absolute_url ) {
198 $link = admin_url( 'admin.php' ) . '?page=' . $link ;
199 }
200
201 return $link;
202 }
203
204
205 // ---------------------------------------------------------------------------------------------------------------------
206 // == URL of Admin Menu pages ==
207 // ---------------------------------------------------------------------------------------------------------------------
208
209 /**
210 * Get URL of Booking Listing or Calendar Overview page
211 *
212 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
213 * @param boolean $is_old - { default: true }
214 * @return string - URL to menu
215 */
216 function wpbc_get_bookings_url( $is_absolute_url = true, $is_old = true ) {
217 return wpbc_get_menu_url( 'booking', $is_absolute_url, $is_old );
218 }
219
220 /**
221 * Get URL of Booking > Availability page
222 *
223 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
224 * @param boolean $is_old - { default: true }
225 * @return string - URL to menu
226 */
227 function wpbc_get_availability_url( $is_absolute_url = true, $is_old = true ) {
228 return wpbc_get_menu_url( 'availability', $is_absolute_url, $is_old );
229 }
230
231 /**
232 * Get URL of Booking > Availability > General Availability page.
233 *
234 * @param boolean $is_absolute_url Absolute or relative url { default: true }.
235 * @param boolean $is_old Legacy compatibility flag.
236 *
237 * @return string URL to General Availability page.
238 */
239 function wpbc_get_general_availability_url( $is_absolute_url = true, $is_old = true ) {
240 return wpbc_get_availability_url( $is_absolute_url, $is_old ) . '&tab=general_availability';
241 }
242
243 /**
244 * Get URL of Booking > Availability > Time Slots Availability page.
245 *
246 * @param boolean $is_absolute_url Absolute or relative url { default: true }.
247 * @param boolean $is_old Legacy compatibility flag.
248 *
249 * @return string URL to Time Slots Availability page.
250 */
251 function wpbc_get_time_slots_availability_url( $is_absolute_url = true, $is_old = true ) {
252 return wpbc_get_availability_url( $is_absolute_url, $is_old ) . '&tab=time_slots_availability';
253 }
254
255 /**
256 * Get URL of Booking > Availability page
257 *
258 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
259 * @param boolean $is_old - { default: true }
260 * @return string - URL to menu
261 */
262 function wpbc_get_price_url( $is_absolute_url = true, $is_old = true ) {
263 return wpbc_get_menu_url( 'price', $is_absolute_url, $is_old );
264 }
265
266 /**
267 * Get URL of Booking > Add booking page
268 *
269 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
270 * @param boolean $is_old - { default: true }
271 * @return string - URL to menu
272 */
273 function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) {
274 return wpbc_get_menu_url( 'add', $is_absolute_url, $is_old );
275 }
276
277 /**
278 * Get URL of Booking > Resources page
279 *
280 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
281 * @param boolean $is_old - { default: true }
282 * @return string - URL to menu
283 */
284 function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) {
285 return wpbc_get_menu_url( 'resources', $is_absolute_url, $is_old );
286 }
287
288 /**
289 * Get URL of Booking > Resources > Capacity page
290 *
291 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
292 * @param boolean $is_old - { default: true }
293 * @return string - URL to menu
294 */
295 function wpbc_get_resource_capacity_url( $is_absolute_url = true, $is_old = true ) {
296 return wpbc_get_resources_url( $is_absolute_url, $is_old ) . '&tab=capacity';
297 }
298
299 /**
300 * Get URL of Booking > Settings page
301 *
302 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
303 * @param boolean $is_old - { default: true }
304 * @return string - URL to menu
305 */
306 function wpbc_get_settings_url( $is_absolute_url = true, $is_old = true ) {
307 return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old );
308 }
309
310 /**
311 * Get URL of Booking > Settings > Calendar page
312 *
313 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
314 * @param boolean $is_old - { default: true }
315 * @return string - URL to menu
316 */
317 function wpbc_get_settings_calendar_url( $is_absolute_url = true, $is_old = true ) {
318 return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=calendar_settings';
319 }
320
321 /**
322 * Get URL of Booking > Settings > Appearance / Theme page
323 *
324 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
325 * @param boolean $is_old - { default: true }
326 * @return string - URL to menu
327 */
328 function wpbc_get_settings_themes_url( $is_absolute_url = true, $is_old = true ) {
329 return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=themes';
330 }
331
332 /**
333 * Get URL of Booking > Settings > Form Messages page.
334 *
335 * @param boolean $is_absolute_url Absolute or relative URL.
336 * @param boolean $is_old Legacy menu URL style.
337 * @return string
338 */
339 function wpbc_get_settings_messages_url( $is_absolute_url = true, $is_old = true ) {
340 return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=form_messages';
341 }
342
343 /**
344 * Get URL of Booking > Setup page
345 *
346 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
347 * @param boolean $is_old - { default: true }
348 * @return string - URL to menu
349 */
350 function wpbc_get_setup_wizard_page_url( $is_absolute_url = true, $is_old = true ) {
351 return wpbc_get_menu_url( 'setup', $is_absolute_url, $is_old );
352 }
353
354
355 // -----------------------------------------------------------------------------------------------------------------
356 // == Is this specific admin page ? ==
357 // ---------------------------------------------------------------------------------------------------------------------
358
359 /**
360 * Check if this Booking Listing or Calendar Overview page
361 *
362 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
363 *
364 * @return boolean true | false
365 */
366 function wpbc_is_this_plugin_page( $server_param = 'REQUEST_URI' ) {
367
368 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
369 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) ) {
370 return true;
371 }
372
373 return false;
374 }
375
376 /**
377 * Check if this Booking Listing or Calendar Overview page
378 *
379 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
380 *
381 * @return boolean true | false
382 */
383 function wpbc_is_bookings_page( $server_param = 'REQUEST_URI' ) {
384 // Old.
385 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
386 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) === false ) ) {
387 return true;
388 }
389 // New.
390 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
391 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-' ) === false ) ) {
392 return true;
393 }
394
395 return false;
396 }
397
398 /**
399 * Check if this Booking > Add booking page
400 *
401 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
402 *
403 * @return boolean true | false
404 */
405 function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) {
406
407 if ( ! is_admin() || empty( $_SERVER[ $server_param ] ) ) {
408 return false;
409 }
410
411 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
412 if ( wpbc_is_new_booking_page_url( $_SERVER[ $server_param ] ) ) {
413 return true;
414 }
415
416 return false;
417 }
418
419 /**
420 * Check if a URL points to Booking > Bookings > Add booking.
421 *
422 * @param string $request_uri URL or request URI.
423 *
424 * @return bool
425 */
426 function wpbc_is_new_booking_page_url( $request_uri ) {
427
428 $request_uri = (string) $request_uri;
429
430 return (
431 ( false !== strpos( $request_uri, 'page=wpbc' ) )
432 && ( false === strpos( $request_uri, 'page=wpbc-' ) )
433 && ( false !== strpos( $request_uri, 'tab=add-booking' ) )
434 );
435 }
436
437 /**
438 * Check if this WP Booking Calendar > Settings > Booking Form page
439 *
440 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
441 *
442 * @return boolean true | false
443 */
444 function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) {
445 // Regular user overwrite settings.
446
447 // Match the legacy `form` tab exactly. A substring check also matched newer
448 // tabs whose names start with `form`, such as `form_messages`.
449 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
450 $request_uri = ! empty( $_SERVER[ $server_param ] ) ? (string) $_SERVER[ $server_param ] : '';
451 $is_form_tab = (bool) preg_match( '/(?:[?&])tab=form(?:&|$)/', $request_uri );
452
453 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
454 $is_multiuser_form_tab = class_exists( 'wpdev_bk_multiuser' ) && ! empty( $_REQUEST['tab'] ) && 'form' === $_REQUEST['tab'];
455
456 if ( is_admin() && false !== strpos( $request_uri, 'page=wpbc-settings' ) && ( $is_form_tab || $is_multiuser_form_tab ) ) {
457 return true;
458 }
459
460 return false;
461 }
462
463
464 /**
465 * Check if this WP Booking Calendar > Settings > Booking Form Builder (BFB) page.
466 *
467 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
468 *
469 * @return boolean true | false
470 */
471 function wpbc_is_settings_bfb_page( $server_param = 'REQUEST_URI' ) {
472 // Regular user overwrite settings.
473
474 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
475 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( ( strpos( $_SERVER[ $server_param ], '&tab=builder_booking_form' ) !== false ) || ( ( class_exists( 'wpdev_bk_multiuser' ) ) && ( ! empty( $_REQUEST['tab'] ) ) && ( 'builder_booking_form' === $_REQUEST['tab'] ) ) ) ) {
476 return true;
477 }
478
479 return false;
480 }
481
482
483 /**
484 * Check if this WP Booking Calendar > Settings > Appearance / Theme page
485 *
486 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
487 *
488 * @return boolean true | false
489 */
490 function wpbc_is_settings_themes_page( $server_param = 'REQUEST_URI' ) {
491 // Regular user overwrite settings.
492
493 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
494 if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=themes' ) ) ) {
495 return true;
496 }
497
498 return false;
499 }
500
501 /**
502 * Check if this WP Booking Calendar > Settings > Calendar page
503 *
504 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
505 *
506 * @return boolean true | false
507 */
508 function wpbc_is_settings_calendar_page( $server_param = 'REQUEST_URI' ) {
509 // Regular user overwrite settings.
510
511 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
512 if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=calendar_settings' ) ) ) {
513 return true;
514 }
515
516 return false;
517 }
518
519 /**
520 * Check if this is WP Booking Calendar > Settings > Form Messages.
521 *
522 * @param string $server_param Server URL parameter.
523 * @return boolean
524 */
525 function wpbc_is_settings_messages_page( $server_param = 'REQUEST_URI' ) {
526 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
527 return is_admin() && ! empty( $_SERVER[ $server_param ] ) && false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) && false !== strpos( $_SERVER[ $server_param ], '&tab=form_messages' );
528 }
529
530 /**
531 * Check if this admin page renders a real front-end booking form or calendar preview.
532 *
533 * @return boolean true | false
534 */
535 function wpbc_is_admin_page_with_frontend_booking_preview() {
536
537 return (
538 wpbc_is_new_booking_page()
539 || wpbc_is_settings_form_page()
540 || wpbc_is_settings_themes_page()
541 || wpbc_is_settings_calendar_page()
542 || wpbc_is_settings_messages_page()
543 || wpbc_is_setup_wizard_page()
544 || wpbc_is_builder_booking_form_page()
545 || ( function_exists( 'wpbc_add_appointment_page_is_active' ) && wpbc_add_appointment_page_is_active() )
546 || ( function_exists( 'wpbc_is_add_booking_modal_on_booking_listing_page' ) && wpbc_is_add_booking_modal_on_booking_listing_page() )
547 );
548 }
549
550 /**
551 * Check if this Booking > Availability page
552 *
553 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
554 *
555 * @return boolean true | false
556 */
557 function wpbc_is_availability_page( $server_param = 'REQUEST_URI' ) {
558
559 // New.
560 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
561 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-availability' ) !== false ) ) {
562 return true;
563 }
564
565 return false;
566 }
567
568 /**
569 * Check if this Booking > Availability page
570 *
571 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
572 *
573 * @return boolean true | false
574 */
575 function wpbc_is_builder_booking_form_page( $server_param = 'REQUEST_URI' ) {
576
577 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
578 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'tab=builder_booking_form' ) !== false ) ) {
579 return true;
580 }
581
582 return false;
583 }
584
585
586 /**
587 * Check if this Booking > Setup page
588 *
589 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
590 *
591 * @return boolean true | false
592 */
593 function wpbc_is_setup_wizard_page( $server_param = 'REQUEST_URI' ) { // FixIn: 9.8.0.1.
594
595 // New.
596 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
597 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) {
598 return true;
599 }
600
601 return false;
602 }
603
604 /**
605 * Check if this Booking > Resources page
606 *
607 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
608 *
609 * @return boolean true | false
610 */
611 function wpbc_is_resources_page( $server_param = 'REQUEST_URI' ) {
612
613 // Old.
614 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
615 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-resources' ) !== false ) ) {
616 return true;
617 }
618 // New.
619 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
620 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-resources' ) !== false ) ) {
621 return true;
622 }
623
624 return false;
625 }
626
627 /**
628 * Check if this Booking > Settings page
629 *
630 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
631 *
632 * @return boolean true | false
633 */
634 function wpbc_is_settings_page( $server_param = 'REQUEST_URI' ) {
635
636 // Old.
637 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
638 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-option' ) !== false ) ) {
639 return true;
640 }
641 // New.
642 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
643 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) ) {
644 return true;
645 }
646
647 return false;
648 }
649
650
651 // -----------------------------------------------------------------------------------------------------------------
652 // == support ==
653 // ---------------------------------------------------------------------------------------------------------------------
654
655 /**
656 * Transform the REQUEST parameters (GET and POST) into URL
657 *
658 * @param $page_param
659 * @param $exclude_params
660 * @param $only_these_parameters
661 * @param $is_escape_url
662 * @param $only_get
663 *
664 * @return string|null
665 */
666 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
667
668 $exclude_params[] = 'page';
669 $exclude_params[] = 'post_type';
670
671 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
672 if ( isset( $_GET['page'] ) ) {
673 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
674 $page_param = $_GET['page'];
675 }
676 $get_paramaters = array( 'page' => $page_param );
677 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
678 $check_params = ( $only_get ) ? $_GET : $_REQUEST;
679
680
681 foreach ( $check_params as $prm_key => $prm_value ) {
682
683 // Skip parameters arrays, like $_GET['rvaluation_to'] = Array ( [0] => 6, [1] => 14, [2] => 14 )
684 if (
685 ( is_string( $prm_value ) )
686 || ( is_numeric( $prm_value ) )
687 ){
688
689 // Check about Too long parameters, if it exists then reset it.
690 if ( strlen( $prm_value ) > 1000 ) {
691 $prm_value = '';
692 }
693
694 if ( ! in_array( $prm_key, $exclude_params ) ) {
695 if ( ( $only_these_parameters === false ) || ( in_array( $prm_key, $only_these_parameters ) ) ) {
696 $get_paramaters[ $prm_key ] = $prm_value;
697 }
698 }
699
700 }
701 }
702
703 $url = admin_url( add_query_arg( $get_paramaters , 'admin.php' ) );
704
705 if ( $is_escape_url ) {
706 $url = esc_url_raw( $url ); // FixIn: 8.1.1.7.
707 }
708
709 return $url;
710 }
711
712
713 function wpbc_left_vertival_nav__get_tab_url( $page_tag, $tab_name, $subtab_name = false, $tags = array( 'tab' => 'tab', 'subtab' => 'subtab' ) ) {
714
715 if ( false === $subtab_name ) {
716 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, ), 'admin.php' ) ) );
717 } else {
718 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, $tags['subtab'] => $subtab_name, ), 'admin.php' ) ) );
719 }
720 }
721
722 /**
723 * Get back URL for going from edit season filter or rate to specfic main page.
724 *
725 * @return string|null
726 */
727 function wpbc_get_back_button_url__for_seasons() {
728
729 $page_params_arr = array(
730 'page' => 'wpbc-availability',
731 'page_num' => 1,
732 );
733
734 if ( ! empty( $_REQUEST['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
735 $page_params_arr['page'] = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
736 }
737 if ( ! empty( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
738 $page_params_arr['tab'] = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
739 }
740 if ( ! empty( $_REQUEST['page_num'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
741 $page_params_arr['page_num'] = intval( $_REQUEST['page_num'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
742 }
743
744 $back_url = admin_url(
745 add_query_arg(
746 $page_params_arr,
747 'admin.php'
748 )
749 );
750 return $back_url;
751 }
752