network_site_url
Retrieves the site URL for the current network.
Description
Returns the site URL with the appropriate protocol, https if
and http, otherwise. If is_ssl(…)
$scheme
is http, or https ,
is overridden.is_ssl(…)
Returns (string)
Site URL link with optional path appended.
Parameters (2)
- 0. $path — Optional. (string) =>
''
- Path relative to the site URL. Default empty.
- 1. $scheme — Optional. (null) =>
null
- Scheme to give the site URL context. Accepts http,, https., or relative. Default null.
Usage
if ( !function_exists( 'network_site_url' ) ) { require_once ABSPATH . WPINC . '/link-template.php'; } // Optional. Path relative to the site URL. Default empty. $path = ''; // Optional. Scheme to give the site URL context. Accepts // 'http', 'https', or 'relative'. Default null. $scheme = null; // NOTICE! Understand what this does before running. $result = network_site_url($path, $scheme);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/link-template.php
- function network_site_url( $path = '', $scheme = null ) {
- if ( ! is_multisite() )
- return site_url($path, $scheme);
- $current_network = get_network();
- if ( 'relative' == $scheme )
- $url = $current_network->path;
- else
- $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
- if ( $path && is_string( $path ) )
- $url .= ltrim( $path, '/' );
- /**
- * Filters the network site URL.
- *
- * @since 3.0.0
- *
- * @param string $url The complete network site URL including scheme and path.
- * @param string $path Path relative to the network site URL. Blank string if
- * no path is specified.
- * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https',
- * 'relative' or null.
- */
- return apply_filters( 'network_site_url', $url, $path, $scheme );
- }