On this page
network_site_url( string $path = '', string|null $scheme = null ): string
Retrieves the site URL for the current network.
Description
Returns the site URL with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.
See also
Parameters
$pathstring Optional-
Path relative to the site URL.
Default:
'' $schemestring|null Optional-
Scheme to give the site URL context. Accepts
'http','https', or'relative'.Default:
null
Return
string Site URL link with optional path appended.
Source
File: wp-includes/link-template.php. View all references
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 );
}
Hooks
- apply_filters( 'network_site_url',
string $url ,string $path ,string|null $scheme ) -
Filters the network site URL.
Related
Uses
| Uses | Description |
|---|---|
| get_network() wp-includes/ms-network.php | Retrieves network data given a network ID or network object. |
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| site_url() wp-includes/link-template.php | Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| retrieve_password() wp-includes/user.php | Handles sending a password retrieval email to a user. |
| wp_new_user_notification() wp-includes/pluggable.php | Emails login credentials to a newly-registered user. |
| wp_lostpassword_url() wp-includes/general-template.php | Returns the URL that allows the user to reset the lost password. |
| network_admin_url() wp-includes/link-template.php | Retrieves the URL to the admin area for the network. |
| user_admin_url() wp-includes/link-template.php | Retrieves the URL to the admin area for the current user. |
| wp_version_check() wp-includes/update.php | Checks WordPress version against the newest version. |
| redirect_canonical() wp-includes/canonical.php | Redirects incoming links to the proper URL based on the site url. |
| wpmu_signup_blog_notification() wp-includes/ms-functions.php | Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/network_site_url