PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.0
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.0
6.2.1 6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / libraries / framework / Supports / Url.php
kirki / libraries / framework / Supports Last commit date
Facades 1 week ago Traits 1 month ago Arr.php 1 week ago DataCaster.php 1 month ago Fluent.php 1 week ago HigherOrderTapProxy.php 1 month ago MediaAttachment.php 1 month ago MessagesBag.php 1 week ago Somoy.php 1 week ago Str.php 1 week ago Url.php 1 month ago Utils.php 1 month ago
Url.php
83 lines
1 <?php
2
3 /**
4 * WordPress URL helper for building query-string URLs and performing redirects.
5 * Uses add_query_arg and wp_safe_redirect with a JavaScript fallback when headers are already sent.
6 * Supports redirect_back via wp_get_referer.
7 *
8 * @package Framework
9 * @subpackage Supports
10 * @since 1.0.0
11 */
12 namespace Kirki\Framework\Supports;
13
14 \defined('ABSPATH') || exit;
15 class Url
16 {
17 /**
18 * Make.
19 *
20 * @param mixed $url The url.
21 * @param mixed $data The data payload.
22 *
23 * @return void
24 *
25 * @since 1.0.0
26 */
27 public static function make($url, $data = [])
28 {
29 $referer = $url;
30 return add_query_arg($data, $referer);
31 }
32 /**
33 * Redirect.
34 *
35 * @param mixed $url The url.
36 * @param mixed $data The data payload.
37 *
38 * @return void
39 *
40 * @since 1.0.0
41 */
42 public static function redirect($url, $data = [])
43 {
44 $referer = $url;
45 $redirect_url = add_query_arg($data, $referer);
46 static::perform_redirect($redirect_url);
47 }
48 /**
49 * Redirect back.
50 *
51 * @param mixed $data The data payload.
52 *
53 * @return void
54 *
55 * @since 1.0.0
56 */
57 public static function redirect_back($data = [])
58 {
59 $referer = wp_get_referer();
60 $redirect_url = add_query_arg($data, $referer);
61 static::perform_redirect($redirect_url);
62 }
63 /**
64 * Perform redirect.
65 *
66 * @param mixed $redirect_url The redirect url.
67 *
68 * @return void
69 *
70 * @since 1.0.0
71 */
72 protected static function perform_redirect($redirect_url)
73 {
74 if (\headers_sent()) {
75 $safe_url = esc_url($redirect_url);
76 echo '<script>window.location.href = ' . wp_json_encode($safe_url) . ';</script>';
77 exit;
78 }
79 wp_safe_redirect($redirect_url);
80 exit;
81 }
82 }
83