network_home_url

Definition:
function network_home_url( $path = '', $scheme = null ) {}

Retrieve the home url for the current network.
Returns the home url with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.

Parameters

  • string $path: (optional) Path relative to the home url.
  • string $scheme: (optional) Scheme to give the home url context. Currently ‘http’, ‘https’.

Return values

returns:Home url link with optional path appended.

Defined filters

  • network_home_url
    apply_filters( 'network_home_url', $url, $path, $orig_scheme)

Source code

function network_home_url( $path = '', $scheme = null ) {

	global $current_site;



	if ( !is_multisite() )

		return home_url($path, $scheme);



	$orig_scheme = $scheme;



	if ( !in_array($scheme, array('http', 'https')) )

		$scheme = is_ssl() && !is_admin() ? 'https' : 'http';



	$url = $scheme . '://' . $current_site->domain . $current_site->path;



	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )

		$url .= ltrim( $path, '/' );



	return apply_filters( 'network_home_url', $url, $path, $orig_scheme);

}

2425

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: