Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_home_url [ WordPress Function ]

get_home_url ( $blog_id = null, $path = '', $scheme = null )
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', or 'relative'.
Returns:
  • (string) Home url link with optional path appended.
Defined at:



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.

Source


<?php
function get_home_url$blog_id null$path ''$scheme null ) {
    
$orig_scheme $scheme;

    if ( !
in_array$scheme, array( 'http''https''relative' ) ) )
        
$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 ( 
'relative' == $scheme )
        
$url preg_replace'#^.+://[^/]*#'''$url );
    elseif ( 
'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 );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics