Advertisements

get_site_url

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

Retrieve the site url for a given site.
Returns the ‘site_url’ option with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.

Parameters

  • int $blog_id: (optional) Blog ID. Defaults to current blog.
  • string $path: Optional. Path relative to the site url.
  • string $scheme: Optional. Scheme to give the site url context. Currently ‘http’, ‘https’, ‘login’, ‘login_post’, or ‘admin’.

Return values

returns:Site url link with optional path appended.

Source code

function get_site_url( $blog_id = null, $path = '', $scheme = null ) {

	// should the list of allowed schemes be maintained elsewhere?

	$orig_scheme = $scheme;

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

		if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )

			$scheme = 'https';

		elseif ( ( 'login' == $scheme ) && force_ssl_admin() )

			$scheme = 'https';

		elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )

			$scheme = 'https';

		else

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

	}



	if ( empty( $blog_id ) || !is_multisite() )

		$url = get_option( 'siteurl' );

	else

		$url = get_blog_option( $blog_id, 'siteurl' );



	if ( 'http' != $scheme )

		$url = str_replace( 'http://', "{$scheme}://", $url );

1701

Advertisements

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: