PluginProbe
Redirection / 2.7
Redirection v2.7
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
← All changes | matches/url.php +10 -28 4.22.7 View file →
@@ -1,18 +1,14 @@
1 1 <?php
2 2
3 3 class URL_Match extends Red_Match {
4 - public $url = false;
5 -
6 - public function name() {
4 + function name () {
7 5 return __( 'URL only', 'redirection' );
8 6 }
9 7
10 8 public function save( array $details, $no_target_url = false ) {
11 - $data = isset( $details['url'] ) ? $details['url'] : '';
12 -
13 - if ( strlen( $data ) === 0 ) {
14 - $data = '/';
9 + if ( ! isset( $details['action_data'] ) || strlen( $details['action_data'] ) === 0 ) {
10 + $details['action_data'] = '/';
15 11 }
16 12
17 13 if ( $no_target_url ) {
18 14 return null;
@@ -17,34 +13,20 @@
17 13 if ( $no_target_url ) {
18 14 return null;
19 15 }
20 16
21 - return $this->sanitize_url( $data );
17 + return $this->sanitize_url( $details['action_data'] );
22 18 }
23 19
24 - public function is_match( $url ) {
25 - return true;
26 - }
27 -
28 - public function get_target_url( $requested_url, $source_url, Red_Source_Flags $flags, $matched ) {
20 + function get_target( $url, $matched_url, $regex ) {
29 21 $target = $this->url;
30 - if ( $flags->is_regex() ) {
31 - $target = $this->get_target_regex_url( $source_url, $target, $requested_url, $flags );
22 + if ( $regex ) {
23 + $target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url, $url );
32 24 }
33 25
34 - return $target;
35 - }
36 -
37 - public function get_data() {
38 - if ( $this->url ) {
39 - return array(
40 - 'url' => $this->url,
41 - );
26 + if ( $target === '' ) {
27 + return $matched_url;
42 28 }
43 29
44 - return '';
45 - }
46 -
47 - public function load( $values ) {
48 - $this->url = $values;
30 + return $target;
49 31 }
50 32 }