Switch language

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




get_site_url [ WordPress Function ]

get_site_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 site url.
  • (string) $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
Returns:
  • (string) Site url link with optional path appended.
Defined at:



Retrieve the site url for a given site.

Returns the 'site_url' 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_site_url$blog_id null$path ''$scheme null ) {
    
// should the list of allowed schemes be maintained elsewhere?
    
$orig_scheme $scheme;
    if ( !
in_array$scheme, array( 'http''https''relative' ) ) ) {
        if ( ( 
'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
            
$scheme 'https';
        elseif ( ( 
'login' == $scheme ) && force_ssl_admin() )
            
$scheme 'https';
        elseif ( ( 
'admin' == $scheme ) && force_ssl_admin() )
            
$scheme 'https';
        else
            
$scheme = ( is_ssl() ? 'https' 'http' );
    }

    if ( empty( 
$blog_id ) || !is_multisite() )
        
$url get_option'siteurl' );
    else
        
$url get_blog_option$blog_id'siteurl' );

    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'site_url'$url$path$orig_scheme$blog_id );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



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