Yoast\WP\SEO\Helpers

Url_Helper::home()publicYoast 1.0

Retrieve home URL with proper trailing slash.

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

Хуков нет.

Возвращает

Строку. Home URL with optional path, appropriately slashed if not.

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

$Url_Helper = new Url_Helper();
$Url_Helper->home( $path, $scheme );
$path(строка)
Path relative to home URL.
По умолчанию: ''
$scheme(строка|null)
Scheme to apply.
По умолчанию: null

Код Url_Helper::home() Yoast 22.3

public function home( $path = '', $scheme = null ) {
	$home_url = \home_url( $path, $scheme );

	if ( ! empty( $path ) ) {
		return $home_url;
	}

	$home_path = \wp_parse_url( $home_url, \PHP_URL_PATH );

	if ( $home_path === '/' ) { // Home at site root, already slashed.
		return $home_url;
	}

	if ( \is_null( $home_path ) ) { // Home at site root, always slash.
		return \trailingslashit( $home_url );
	}

	if ( \is_string( $home_path ) ) { // Home in subdirectory, slash if permalink structure has slash.
		return \user_trailingslashit( $home_url );
	}

	return $home_url;
}