public function getValidationPattern( $url, $wrap = true ) {
		$parameters = [];

		// Replace all parameters with placeholders
		$validation_pattern = preg_replace_callback( $this->url_pattern, function ( $matches ) use ( &$parameters ) {
			return $this->replacePatternParameterWithPlaceholder( $matches, $parameters );
		}, $url );

		// Quote the remaining string so that it does not get evaluated as a pattern.
		$validation_pattern = preg_quote( $validation_pattern, '~' );

		// Replace the placeholders with the real parameter patterns.
		$validation_pattern = str_replace(
			array_keys( $parameters ),
			array_values( $parameters ),
			$validation_pattern
		);

		// Match the entire url; make trailing slash optional.
		$validation_pattern = '^' . $validation_pattern . '?$';

		if ( $wrap ) {
			$validation_pattern = '~' . $validation_pattern . '~';
		}

		return $validation_pattern;
	}