# redirection/3.7/matches/url.php

Redirection, version 3.7. 51 lines.

- Page: https://pluginprobe.com/plugins/redirection/3.7/code/matches/url.php
- Raw: https://pluginprobe.com/plugins/redirection/3.7/raw/matches/url.php
- Modified: 2018-11-03T13:26:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/redirection/3.7/code/matches/url.php#L10-L20`.

```php
<?php

class URL_Match extends Red_Match {
	public $url = false;

	function name() {
		return __( 'URL only', 'redirection' );
	}

	public function save( array $details, $no_target_url = false ) {
		$data = isset( $details['url'] ) ? $details['url'] : '';

		if ( strlen( $data ) === 0 ) {
			$data = '/';
		}

		if ( $no_target_url ) {
			return null;
		}

		return $this->sanitize_url( $data );
	}

	function get_target( $url, $matched_url, $regex ) {
		$target = $this->url;
		if ( $regex ) {
			$target = $this->get_target_regex_url( $matched_url, $this->url, $url );
		}

		if ( $target === '' ) {
			return $matched_url;
		}

		return $target;
	}

	public function get_data() {
		if ( $this->url ) {
			return array(
				'url' => $this->url,
			);
		}

		return '';
	}

	public function load( $values ) {
		$this->url = $values;
	}
}

```
