PluginProbe
Redirection / 4.0
Redirection v4.0
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / models / url-path.php

url-path.php in Redirection 4.0, at models/url-path.php

33 lines 690 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Red_Url_Path {
4 public function __construct( $url ) {
5 $this->path = $this->get_url_path( $url );
6 }
7
8 private function get_url_path( $url ) {
9 $path = wp_parse_url( $url, PHP_URL_PATH );
10
11 return $path ? $path : '/';
12 }
13
14 public function is_match( $url, Red_Source_Flags $flags ) {
15 $source = $this->path;
16 $target = $this->get_url_path( $url );
17
18 if ( $flags->is_ignore_case() ) {
19 // Case insensitive match
20 $source = strtolower( $source );
21 $target = strtolower( $target );
22 }
23
24 if ( $flags->is_ignore_trailing() ) {
25 // Ignore trailing slashes
26 $source = rtrim( $source, '/' );
27 $target = rtrim( $target, '/' );
28 }
29
30 return $target === $source;
31 }
32 }
33