| 1 |
<?php |
| 2 |
|
| 3 |
class Red_Url_Match { |
| 4 |
public function __construct( $url ) { |
| 5 |
$this->url = $url; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Get the plain 'matched' URL: |
| 10 |
* |
| 11 |
* - Lowercase |
| 12 |
* - No trailing slashes |
| 13 |
* |
| 14 |
* @return string URL |
| 15 |
*/ |
| 16 |
public function get_url() { |
| 17 |
// Remove query params |
| 18 |
$path = wp_parse_url( $this->url, PHP_URL_PATH ); |
| 19 |
|
| 20 |
// Lowercase everything |
| 21 |
$path = strtolower( $path ); |
| 22 |
|
| 23 |
// Trim trailing slash |
| 24 |
$path = rtrim( $path, '/' ); |
| 25 |
|
| 26 |
return $path ? $path : '/'; |
| 27 |
} |
| 28 |
} |
| 29 |
|