improvements to get_home/site_url, props andreasnrb + code cleanup, see #12735

git-svn-id: http://svn.automattic.com/wordpress/trunk@14702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-05-16 21:58:31 +00:00
parent bd467ad036
commit 021179162a
1 changed files with 13 additions and 13 deletions

View File

@ -1846,13 +1846,13 @@ function home_url( $path = '', $scheme = null ) {
function get_home_url( $blog_id = null, $path = '', $scheme = null ) { function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
$orig_scheme = $scheme; $orig_scheme = $scheme;
if ( !in_array($scheme, array('http', 'https')) ) if ( !in_array( $scheme, array( 'http', 'https' ) ) )
$scheme = is_ssl() && !is_admin() ? 'https' : 'http'; $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
if ( empty($blog_id) || !is_multisite() ) if ( empty( $blog_id ) || !is_multisite() )
$home = get_option('home'); $home = get_option( 'home' );
else else
$home = untrailingslashit(get_blogaddress_by_id($blog_id)); $home = get_blog_option( $blog_id, 'home' );
$url = str_replace( 'http://', "$scheme://", $home ); $url = str_replace( 'http://', "$scheme://", $home );
@ -1900,28 +1900,28 @@ function site_url( $path = '', $scheme = null ) {
function get_site_url( $blog_id = null, $path = '', $scheme = null ) { function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
// should the list of allowed schemes be maintained elsewhere? // should the list of allowed schemes be maintained elsewhere?
$orig_scheme = $scheme; $orig_scheme = $scheme;
if ( !in_array($scheme, array('http', 'https')) ) { if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) ) if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
$scheme = 'https'; $scheme = 'https';
elseif ( ('login' == $scheme) && ( force_ssl_admin() ) ) elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
$scheme = 'https'; $scheme = 'https';
elseif ( ('admin' == $scheme) && force_ssl_admin() ) elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
$scheme = 'https'; $scheme = 'https';
else else
$scheme = ( is_ssl() ? 'https' : 'http' ); $scheme = ( is_ssl() ? 'https' : 'http' );
} }
if ( empty($blog_id) || !is_multisite() ) if ( empty( $blog_id ) || !is_multisite() )
$url = get_option('siteurl'); $url = get_option( 'siteurl' );
else else
$url = untrailingslashit(get_blogaddress_by_id($blog_id)); $url = get_blog_option( $blog_id, 'siteurl' );
$url = str_replace( 'http://', "{$scheme}://", $url ); $url = str_replace( 'http://', "{$scheme}://", $url );
if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
$url .= '/' . ltrim($path, '/'); $url .= '/' . ltrim( $path, '/' );
return apply_filters('site_url', $url, $path, $orig_scheme, $blog_id); return apply_filters( 'site_url', $url, $path, $orig_scheme, $blog_id );
} }
/** /**