PluginProbe
Booking Calendar / 11.0
Booking Calendar v11.0
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
booking / includes / _functions / admin_menu_url.php

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

651 lines 24.7 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 > Settings 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_settings_url( $is_absolute_url = true, $is_old = true ) {
296 return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old );
297 }
298
299 /**
300 * Get URL of Booking > Setup 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_setup_wizard_page_url( $is_absolute_url = true, $is_old = true ) {
307 return wpbc_get_menu_url( 'setup', $is_absolute_url, $is_old );
308 }
309
310
311 // -----------------------------------------------------------------------------------------------------------------
312 // == Is this specific admin page ? ==
313 // ---------------------------------------------------------------------------------------------------------------------
314
315 /**
316 * Check if this Booking Listing or Calendar Overview page
317 *
318 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
319 *
320 * @return boolean true | false
321 */
322 function wpbc_is_this_plugin_page( $server_param = 'REQUEST_URI' ) {
323
324 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
325 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) ) {
326 return true;
327 }
328
329 return false;
330 }
331
332 /**
333 * Check if this Booking Listing or Calendar Overview page
334 *
335 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
336 *
337 * @return boolean true | false
338 */
339 function wpbc_is_bookings_page( $server_param = 'REQUEST_URI' ) {
340 // Old.
341 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
342 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) === false ) ) {
343 return true;
344 }
345 // New.
346 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
347 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-' ) === false ) ) {
348 return true;
349 }
350
351 return false;
352 }
353
354 /**
355 * Check if this Booking > Add booking page
356 *
357 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
358 *
359 * @return boolean true | false
360 */
361 function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) {
362
363 if ( ! is_admin() || empty( $_SERVER[ $server_param ] ) ) {
364 return false;
365 }
366
367 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
368 if ( wpbc_is_new_booking_page_url( $_SERVER[ $server_param ] ) ) {
369 return true;
370 }
371
372 return false;
373 }
374
375 /**
376 * Check if a URL points to Booking > Bookings > Add booking.
377 *
378 * @param string $request_uri URL or request URI.
379 *
380 * @return bool
381 */
382 function wpbc_is_new_booking_page_url( $request_uri ) {
383
384 $request_uri = (string) $request_uri;
385
386 return (
387 ( false !== strpos( $request_uri, 'page=wpbc' ) )
388 && ( false === strpos( $request_uri, 'page=wpbc-' ) )
389 && ( false !== strpos( $request_uri, 'tab=add-booking' ) )
390 );
391 }
392
393 /**
394 * Check if this WP Booking Calendar > Settings > Booking Form page
395 *
396 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
397 *
398 * @return boolean true | false
399 */
400 function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) {
401 // Regular user overwrite settings.
402
403 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
404 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( ( strpos( $_SERVER[ $server_param ], '&tab=form' ) !== false ) || ( ( class_exists( 'wpdev_bk_multiuser' ) ) && ( ! empty( $_REQUEST['tab'] ) ) && ( 'form' === $_REQUEST['tab'] ) ) ) ) {
405 return true;
406 }
407
408 return false;
409 }
410
411
412 /**
413 * Check if this WP Booking Calendar > Settings > Booking Form Builder (BFB) page.
414 *
415 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
416 *
417 * @return boolean true | false
418 */
419 function wpbc_is_settings_bfb_page( $server_param = 'REQUEST_URI' ) {
420 // Regular user overwrite settings.
421
422 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
423 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'] ) ) ) ) {
424 return true;
425 }
426
427 return false;
428 }
429
430
431 /**
432 * Check if this WP Booking Calendar > Settings > Booking Form page
433 *
434 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
435 *
436 * @return boolean true | false
437 */
438 function wpbc_is_settings_color_themes_page( $server_param = 'REQUEST_URI' ) {
439 // Regular user overwrite settings.
440
441 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
442 if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=color_themes' ) ) ) {
443 return true;
444 }
445
446 return false;
447 }
448
449 /**
450 * Check if this Booking > Availability page
451 *
452 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
453 *
454 * @return boolean true | false
455 */
456 function wpbc_is_availability_page( $server_param = 'REQUEST_URI' ) {
457
458 // New.
459 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
460 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-availability' ) !== false ) ) {
461 return true;
462 }
463
464 return false;
465 }
466
467 /**
468 * Check if this Booking > Availability page
469 *
470 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
471 *
472 * @return boolean true | false
473 */
474 function wpbc_is_builder_booking_form_page( $server_param = 'REQUEST_URI' ) {
475
476 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
477 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'tab=builder_booking_form' ) !== false ) ) {
478 return true;
479 }
480
481 return false;
482 }
483
484
485 /**
486 * Check if this Booking > Setup page
487 *
488 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
489 *
490 * @return boolean true | false
491 */
492 function wpbc_is_setup_wizard_page( $server_param = 'REQUEST_URI' ) { // FixIn: 9.8.0.1.
493
494 // New.
495 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
496 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) {
497 return true;
498 }
499
500 return false;
501 }
502
503 /**
504 * Check if this Booking > Resources page
505 *
506 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
507 *
508 * @return boolean true | false
509 */
510 function wpbc_is_resources_page( $server_param = 'REQUEST_URI' ) {
511
512 // Old.
513 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
514 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-resources' ) !== false ) ) {
515 return true;
516 }
517 // New.
518 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
519 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-resources' ) !== false ) ) {
520 return true;
521 }
522
523 return false;
524 }
525
526 /**
527 * Check if this Booking > Settings page
528 *
529 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
530 *
531 * @return boolean true | false
532 */
533 function wpbc_is_settings_page( $server_param = 'REQUEST_URI' ) {
534
535 // Old.
536 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
537 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-option' ) !== false ) ) {
538 return true;
539 }
540 // New.
541 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
542 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) ) {
543 return true;
544 }
545
546 return false;
547 }
548
549
550 // -----------------------------------------------------------------------------------------------------------------
551 // == support ==
552 // ---------------------------------------------------------------------------------------------------------------------
553
554 /**
555 * Transform the REQUEST parameters (GET and POST) into URL
556 *
557 * @param $page_param
558 * @param $exclude_params
559 * @param $only_these_parameters
560 * @param $is_escape_url
561 * @param $only_get
562 *
563 * @return string|null
564 */
565 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
566
567 $exclude_params[] = 'page';
568 $exclude_params[] = 'post_type';
569
570 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
571 if ( isset( $_GET['page'] ) ) {
572 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
573 $page_param = $_GET['page'];
574 }
575 $get_paramaters = array( 'page' => $page_param );
576 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
577 $check_params = ( $only_get ) ? $_GET : $_REQUEST;
578
579
580 foreach ( $check_params as $prm_key => $prm_value ) {
581
582 // Skip parameters arrays, like $_GET['rvaluation_to'] = Array ( [0] => 6, [1] => 14, [2] => 14 )
583 if (
584 ( is_string( $prm_value ) )
585 || ( is_numeric( $prm_value ) )
586 ){
587
588 // Check about Too long parameters, if it exists then reset it.
589 if ( strlen( $prm_value ) > 1000 ) {
590 $prm_value = '';
591 }
592
593 if ( ! in_array( $prm_key, $exclude_params ) ) {
594 if ( ( $only_these_parameters === false ) || ( in_array( $prm_key, $only_these_parameters ) ) ) {
595 $get_paramaters[ $prm_key ] = $prm_value;
596 }
597 }
598
599 }
600 }
601
602 $url = admin_url( add_query_arg( $get_paramaters , 'admin.php' ) );
603
604 if ( $is_escape_url ) {
605 $url = esc_url_raw( $url ); // FixIn: 8.1.1.7.
606 }
607
608 return $url;
609 }
610
611
612 function wpbc_left_vertival_nav__get_tab_url( $page_tag, $tab_name, $subtab_name = false, $tags = array( 'tab' => 'tab', 'subtab' => 'subtab' ) ) {
613
614 if ( false === $subtab_name ) {
615 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, ), 'admin.php' ) ) );
616 } else {
617 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, $tags['subtab'] => $subtab_name, ), 'admin.php' ) ) );
618 }
619 }
620
621 /**
622 * Get back URL for going from edit season filter or rate to specfic main page.
623 *
624 * @return string|null
625 */
626 function wpbc_get_back_button_url__for_seasons() {
627
628 $page_params_arr = array(
629 'page' => 'wpbc-availability',
630 'page_num' => 1,
631 );
632
633 if ( ! empty( $_REQUEST['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
634 $page_params_arr['page'] = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
635 }
636 if ( ! empty( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
637 $page_params_arr['tab'] = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
638 }
639 if ( ! empty( $_REQUEST['page_num'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
640 $page_params_arr['page_num'] = intval( $_REQUEST['page_num'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
641 }
642
643 $back_url = admin_url(
644 add_query_arg(
645 $page_params_arr,
646 'admin.php'
647 )
648 );
649 return $back_url;
650 }
651