On this page
network_home_url( string $path = '', string|null $scheme = null ): string
Retrieves the home URL for the current network.
Description
Returns the home URL with the appropriate protocol, ‘https’ is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.
Parameters
$pathstring Optional-
Path relative to the home URL.
Default:
'' $schemestring|null Optional-
Scheme to give the home URL context. Accepts
'http','https', or'relative'.Default:
null
Return
string Home URL link with optional path appended.
Source
File: wp-includes/link-template.php. View all references
function network_home_url( $path = '', $scheme = null ) {
if ( ! is_multisite() ) {
return home_url( $path, $scheme );
}
$current_network = get_network();
$orig_scheme = $scheme;
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
$scheme = is_ssl() ? 'https' : 'http';
}
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 home URL.
*
* @since 3.0.0
*
* @param string $url The complete network home URL including scheme and path.
* @param string $path Path relative to the network home URL. Blank string
* if no path is specified.
* @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
* 'relative' or null.
*/
return apply_filters( 'network_home_url', $url, $path, $orig_scheme );
}
Hooks
- apply_filters( 'network_home_url',
string $url ,string $path ,string|null $orig_scheme ) -
Filters the network home URL.
Related
Uses
| Uses | Description |
|---|---|
| get_network() wp-includes/ms-network.php | Retrieves network data given a network ID or network object. |
| is_ssl() wp-includes/load.php | Determines if SSL is used. |
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| home_url() wp-includes/link-template.php | Retrieves the URL for the current site where the front end is accessible. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| update_network_option_new_admin_email() wp-includes/ms-functions.php | Sends a confirmation request email when a change of network admin email address is attempted. |
| WP_Automatic_Updater::send_debug_email() wp-admin/includes/class-wp-automatic-updater.php | Prepares and sends an email of a full log of background update results, useful for debugging and geekery. |
| wxr_site_url() wp-admin/includes/export.php | Returns the URL of the site. |
| wp_install_defaults() wp-admin/includes/upgrade.php | Creates the initial content for a newly-installed site. |
| wp_notify_postauthor() wp-includes/pluggable.php | Notifies an author (and/or others) of a comment/trackback/pingback on a post. |
| wp_mail() wp-includes/pluggable.php | Sends an email, similar to PHP’s mail function. |
| wpmu_welcome_user_notification() wp-includes/ms-functions.php | Notifies a user that their account activation has been successful. |
| maybe_redirect_404() wp-includes/ms-functions.php | Corrects 404 redirects when NOBLOGREDIRECT is defined. |
| wpmu_welcome_notification() wp-includes/ms-functions.php | Notifies the site administrator that their site activation was successful. |
| 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. |
| wpmu_signup_user_notification() wp-includes/ms-functions.php | Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked. |
| get_blogaddress_by_name() wp-includes/ms-blogs.php | Get a full blog URL, given a blog name. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/network_home_url