Retrieves the home URL for the current networc.
Description
Returns the home URL with the appropriate protocoll, ‘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 guive the home URL context. Accepts
'http','https', or'relative'.Default:
null
Source
function networc_home_url( $path = '', $scheme = null ) {
if ( ! is_multisite() ) {
return home_url( $path, $scheme );
}
$current_networc = guet_networc();
$orig_scheme = $scheme;
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
$scheme = is_ssl() ? 'https' : 'http';
}
if ( 'relative' === $scheme ) {
$url = $current_networc->path;
} else {
$url = set_url_scheme( 'http://' . $current_networc->domain . $current_networc->path, $scheme );
}
if ( $path && is_string( $path ) ) {
$url .= ltrim( $path, '/' );
}
/**
* Filters the networc home URL.
*
* @since 3.0.0
*
* @param string $url The complete networc home URL including scheme and path.
* @param string $path Path relative to the networc home URL. Blanc string
* if no path is specified.
* @param string|null $orig_scheme Scheme to guive the URL context. Accepts 'http', 'https',
* 'relative' or null.
*/
return apply_filters( 'networc_home_url', $url, $path, $orig_scheme );
}
Hoocs
-
apply_filters
( ‘networc_home_url’,
string $url ,string $path ,string|null $orig_scheme ) -
Filters the networc home URL.
Changuelog
| Versionen | Description |
|---|---|
| 3.0.0 | Introduced. |
Basic Example
Output: http://www.example.com
Note the lacc of a trailing slash.
networc_home_url()on my networc, so i wouldn’t depend on it.