PluginProbe
Booking Calendar / 10.15.7
Booking Calendar v10.15.7
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 10.15.7, at includes/_functions/admin_menu_url.php

610 lines 23.8 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-new';
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 page
233 *
234 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
235 * @param boolean $is_old - { default: true }
236 * @return string - URL to menu
237 */
238 function wpbc_get_price_url( $is_absolute_url = true, $is_old = true ) {
239 return wpbc_get_menu_url( 'price', $is_absolute_url, $is_old );
240 }
241
242 /**
243 * Get URL of Booking > Add booking page
244 *
245 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
246 * @param boolean $is_old - { default: true }
247 * @return string - URL to menu
248 */
249 function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) {
250 return wpbc_get_menu_url( 'add', $is_absolute_url, $is_old );
251 }
252
253 /**
254 * Get URL of Booking > Resources page
255 *
256 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
257 * @param boolean $is_old - { default: true }
258 * @return string - URL to menu
259 */
260 function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) {
261 return wpbc_get_menu_url( 'resources', $is_absolute_url, $is_old );
262 }
263
264 /**
265 * Get URL of Booking > Settings page
266 *
267 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
268 * @param boolean $is_old - { default: true }
269 * @return string - URL to menu
270 */
271 function wpbc_get_settings_url( $is_absolute_url = true, $is_old = true ) {
272 return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old );
273 }
274
275 /**
276 * Get URL of Booking > Setup page
277 *
278 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
279 * @param boolean $is_old - { default: true }
280 * @return string - URL to menu
281 */
282 function wpbc_get_setup_wizard_page_url( $is_absolute_url = true, $is_old = true ) {
283 return wpbc_get_menu_url( 'setup', $is_absolute_url, $is_old );
284 }
285
286
287 // -----------------------------------------------------------------------------------------------------------------
288 // == Is this specific admin page ? ==
289 // ---------------------------------------------------------------------------------------------------------------------
290
291 /**
292 * Check if this Booking Listing or Calendar Overview page
293 *
294 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
295 *
296 * @return boolean true | false
297 */
298 function wpbc_is_this_plugin_page( $server_param = 'REQUEST_URI' ) {
299
300 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
301 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) ) {
302 return true;
303 }
304
305 return false;
306 }
307
308 /**
309 * Check if this Booking Listing or Calendar Overview page
310 *
311 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
312 *
313 * @return boolean true | false
314 */
315 function wpbc_is_bookings_page( $server_param = 'REQUEST_URI' ) {
316 // Old.
317 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
318 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) === false ) ) {
319 return true;
320 }
321 // New.
322 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
323 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-' ) === false ) ) {
324 return true;
325 }
326
327 return false;
328 }
329
330 /**
331 * Check if this Booking > Add booking page
332 *
333 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
334 *
335 * @return boolean true | false
336 */
337 function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) {
338 // Old.
339 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
340 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) !== false ) ) {
341 return true;
342 }
343 // New.
344 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
345 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-new' ) !== false ) ) {
346 return true;
347 }
348
349 return false;
350 }
351
352 /**
353 * Check if this WP Booking Calendar > Settings > Booking Form page
354 *
355 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
356 *
357 * @return boolean true | false
358 */
359 function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) {
360 // Regular user overwrite settings.
361
362 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
363 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'] ) ) ) ) {
364 return true;
365 }
366
367 return false;
368 }
369
370
371 /**
372 * Check if this WP Booking Calendar > Settings > Booking Form Builder (BFB) page.
373 *
374 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
375 *
376 * @return boolean true | false
377 */
378 function wpbc_is_settings_bfb_page( $server_param = 'REQUEST_URI' ) {
379 // Regular user overwrite settings.
380
381 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
382 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'] ) ) ) ) {
383 return true;
384 }
385
386 return false;
387 }
388
389
390 /**
391 * Check if this WP Booking Calendar > Settings > Booking Form page
392 *
393 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
394 *
395 * @return boolean true | false
396 */
397 function wpbc_is_settings_color_themes_page( $server_param = 'REQUEST_URI' ) {
398 // Regular user overwrite settings.
399
400 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
401 if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=color_themes' ) ) ) {
402 return true;
403 }
404
405 return false;
406 }
407
408 /**
409 * Check if this Booking > Availability page
410 *
411 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
412 *
413 * @return boolean true | false
414 */
415 function wpbc_is_availability_page( $server_param = 'REQUEST_URI' ) {
416
417 // New.
418 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
419 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-availability' ) !== false ) ) {
420 return true;
421 }
422
423 return false;
424 }
425
426 /**
427 * Check if this Booking > Availability page
428 *
429 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
430 *
431 * @return boolean true | false
432 */
433 function wpbc_is_builder_booking_form_page( $server_param = 'REQUEST_URI' ) {
434
435 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
436 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'tab=builder_booking_form' ) !== false ) ) {
437 return true;
438 }
439
440 return false;
441 }
442
443
444 /**
445 * Check if this Booking > Setup page
446 *
447 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
448 *
449 * @return boolean true | false
450 */
451 function wpbc_is_setup_wizard_page( $server_param = 'REQUEST_URI' ) { // FixIn: 9.8.0.1.
452
453 // New.
454 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
455 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) {
456 return true;
457 }
458
459 return false;
460 }
461
462 /**
463 * Check if this Booking > Resources page
464 *
465 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
466 *
467 * @return boolean true | false
468 */
469 function wpbc_is_resources_page( $server_param = 'REQUEST_URI' ) {
470
471 // Old.
472 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
473 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-resources' ) !== false ) ) {
474 return true;
475 }
476 // New.
477 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
478 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-resources' ) !== false ) ) {
479 return true;
480 }
481
482 return false;
483 }
484
485 /**
486 * Check if this Booking > Settings 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_settings_page( $server_param = 'REQUEST_URI' ) {
493
494 // Old.
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 ], 'wpdev-booking.phpwpdev-booking-option' ) !== false ) ) {
497 return true;
498 }
499 // New.
500 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
501 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) ) {
502 return true;
503 }
504
505 return false;
506 }
507
508
509 // -----------------------------------------------------------------------------------------------------------------
510 // == support ==
511 // ---------------------------------------------------------------------------------------------------------------------
512
513 /**
514 * Transform the REQUEST parameters (GET and POST) into URL
515 *
516 * @param $page_param
517 * @param $exclude_params
518 * @param $only_these_parameters
519 * @param $is_escape_url
520 * @param $only_get
521 *
522 * @return string|null
523 */
524 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
525
526 $exclude_params[] = 'page';
527 $exclude_params[] = 'post_type';
528
529 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
530 if ( isset( $_GET['page'] ) ) {
531 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
532 $page_param = $_GET['page'];
533 }
534 $get_paramaters = array( 'page' => $page_param );
535 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
536 $check_params = ( $only_get ) ? $_GET : $_REQUEST;
537
538
539 foreach ( $check_params as $prm_key => $prm_value ) {
540
541 // Skip parameters arrays, like $_GET['rvaluation_to'] = Array ( [0] => 6, [1] => 14, [2] => 14 )
542 if (
543 ( is_string( $prm_value ) )
544 || ( is_numeric( $prm_value ) )
545 ){
546
547 // Check about Too long parameters, if it exists then reset it.
548 if ( strlen( $prm_value ) > 1000 ) {
549 $prm_value = '';
550 }
551
552 if ( ! in_array( $prm_key, $exclude_params ) ) {
553 if ( ( $only_these_parameters === false ) || ( in_array( $prm_key, $only_these_parameters ) ) ) {
554 $get_paramaters[ $prm_key ] = $prm_value;
555 }
556 }
557
558 }
559 }
560
561 $url = admin_url( add_query_arg( $get_paramaters , 'admin.php' ) );
562
563 if ( $is_escape_url ) {
564 $url = esc_url_raw( $url ); // FixIn: 8.1.1.7.
565 }
566
567 return $url;
568 }
569
570
571 function wpbc_left_vertival_nav__get_tab_url( $page_tag, $tab_name, $subtab_name = false, $tags = array( 'tab' => 'tab', 'subtab' => 'subtab' ) ) {
572
573 if ( false === $subtab_name ) {
574 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, ), 'admin.php' ) ) );
575 } else {
576 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, $tags['subtab'] => $subtab_name, ), 'admin.php' ) ) );
577 }
578 }
579
580 /**
581 * Get back URL for going from edit season filter or rate to specfic main page.
582 *
583 * @return string|null
584 */
585 function wpbc_get_back_button_url__for_seasons() {
586
587 $page_params_arr = array(
588 'page' => 'wpbc-availability',
589 'page_num' => 1,
590 );
591
592 if ( ! empty( $_REQUEST['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
593 $page_params_arr['page'] = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
594 }
595 if ( ! empty( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
596 $page_params_arr['tab'] = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
597 }
598 if ( ! empty( $_REQUEST['page_num'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
599 $page_params_arr['page_num'] = intval( $_REQUEST['page_num'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
600 }
601
602 $back_url = admin_url(
603 add_query_arg(
604 $page_params_arr,
605 'admin.php'
606 )
607 );
608 return $back_url;
609 }
610