Definition:
function get_home_url( $blog_id = null, $path = '', $scheme = null ) {}
Retrieve the home url for a given site.
Returns the ‘home’ 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 home url.
- string $scheme: (optional) Scheme to give the home url context. Currently ‘http’, ‘https’.
Return values
returns:Home url link with optional path appended.
Defined filters
- home_url
apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id )
Source code
function get_home_url( $blog_id = null, $path = '', $scheme = null ) { $orig_scheme = $scheme; if ( !in_array( $scheme, array( 'http', 'https' ) ) ) $scheme = is_ssl() && !is_admin() ? 'https' : 'http'; if ( empty( $blog_id ) || !is_multisite() ) $url = get_option( 'home' ); else $url = get_blog_option( $blog_id, 'home' ); if ( 'http' != $scheme ) $url = str_replace( 'http://', "$scheme://", $url ); if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) $url .= '/' . ltrim( $path, '/' ); return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ); }
1418
No comments yet... Be the first to leave a reply!