Automattic\WooCommerce\Internal\Utilities

URL::get_url()publicWC 1.0

Outputs the processed URL.

Borrows from https://www.php.net/manual/en/function.parse-url.php#106731

Метод класса: URL{}

Хуков нет.

Возвращает

Строку.

Использование

$URL = new URL();
$URL->get_url( $component_overrides ): string;
$component_overrides(массив)
If provided, these will override values set in $this->components.
По умолчанию: array()

Код URL::get_url() WC 8.7.0

public function get_url( array $component_overrides = array() ): string {
	$components = array_merge( $this->components, $component_overrides );

	$scheme = null !== $components['scheme'] ? $components['scheme'] . '://' : '//';
	$host   = null !== $components['host'] ? $components['host'] : '';
	$port   = null !== $components['port'] ? ':' . $components['port'] : '';
	$path   = $this->get_path( $components['path'] );

	// Special handling for hostless URLs (typically, filepaths) referencing the current working directory.
	if ( '' === $host && ( '' === $path || '.' === $path ) ) {
		$path = './';
	}

	$user      = null !== $components['user'] ? $components['user'] : '';
	$pass      = null !== $components['pass'] ? ':' . $components['pass'] : '';
	$user_pass = ( ! empty( $user ) || ! empty( $pass ) ) ? $user . $pass . '@' : '';

	$query    = null !== $components['query'] ? '?' . $components['query'] : '';
	$fragment = null !== $components['fragment'] ? '#' . $components['fragment'] : '';

	return $scheme . $user_pass . $host . $port . $path . $query . $fragment;
}