PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.10.0
Fluent Support – Helpdesk & Customer Support Ticket System v1.10.0
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / vendor / wpfluent / framework / src / WPFluent / Http / URL.php

URL.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.10.0, at vendor/wpfluent/framework/src/WPFluent/Http/URL.php

46 lines 915 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\Framework\Http;
4
5 class URL
6 {
7 /**
8 * Get the current URL
9 *
10 * @return string
11 */
12 public function current()
13 {
14 return get_site_url() . rtrim(preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']), '/');
15 }
16
17 /**
18 * Parse a url from uncompiled route
19 *
20 * @param string $url
21 * @param array $params
22 * @return string
23 */
24 public function parse(string $url, array $params)
25 {
26 return preg_replace_callback('#\{[a-zA-Z0-9-_]+\}#', function($matches) use ($params) {
27 foreach ($matches as $match) {
28 $match = str_replace(['{', '}'], ['', ''], $match);
29 if (isset($params[$match])) {
30 return $params[$match];
31 }
32 }
33 }, $url);
34 }
35
36 /**
37 * Returns the string representation of the URL object
38 *
39 * @return string Current URL.
40 */
41 public function __toString()
42 {
43 return $this->current();
44 }
45 }
46