Changeset 21734
- Timestamp:
- 09/04/2012 02:44:17 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r21664 r21734 1877 1877 */ 1878 1878 function home_url( $path = '', $scheme = null ) { 1879 return get_home_url( null, $path, $scheme);1879 return get_home_url( null, $path, $scheme ); 1880 1880 } 1881 1881 … … 1898 1898 $orig_scheme = $scheme; 1899 1899 1900 if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )1900 if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) 1901 1901 $scheme = is_ssl() && !is_admin() ? 'https' : 'http'; 1902 1902 … … 1909 1909 } 1910 1910 1911 if ( 'relative' == $scheme ) 1912 $url = preg_replace( '#^.+://[^/]*#', '', $url ); 1913 elseif ( 'http' != $scheme ) 1914 $url = str_replace( 'http://', "$scheme://", $url ); 1915 1916 if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 1911 $url = set_url_scheme( $url, $scheme ); 1912 1913 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 1917 1914 $url .= '/' . ltrim( $path, '/' ); 1918 1915 … … 1933 1930 * 1934 1931 * @param string $path Optional. Path relative to the site url. 1935 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.1932 * @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme(). 1936 1933 * @return string Site url link with optional path appended. 1937 1934 */ 1938 1935 function site_url( $path = '', $scheme = null ) { 1939 return get_site_url( null, $path, $scheme);1936 return get_site_url( null, $path, $scheme ); 1940 1937 } 1941 1938 … … 1956 1953 */ 1957 1954 function get_site_url( $blog_id = null, $path = '', $scheme = null ) { 1958 // should the list of allowed schemes be maintained elsewhere?1959 $orig_scheme = $scheme;1960 if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {1961 if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )1962 $scheme = 'https';1963 elseif ( ( 'login' == $scheme ) && force_ssl_admin() )1964 $scheme = 'https';1965 elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )1966 $scheme = 'https';1967 else1968 $scheme = ( is_ssl() ? 'https' : 'http' );1969 }1970 1971 1955 if ( empty( $blog_id ) || !is_multisite() ) { 1972 1956 $url = get_option( 'siteurl' ); … … 1977 1961 } 1978 1962 1979 if ( 'relative' == $scheme ) 1980 $url = preg_replace( '#^.+://[^/]*#', '', $url ); 1981 elseif ( 'http' != $scheme ) 1982 $url = str_replace( 'http://', "{$scheme}://", $url ); 1983 1984 if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 1963 $url = set_url_scheme( $url, $scheme ); 1964 1965 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 1985 1966 $url .= '/' . ltrim( $path, '/' ); 1986 1967 1987 return apply_filters( 'site_url', $url, $path, $ orig_scheme, $blog_id );1968 return apply_filters( 'site_url', $url, $path, $scheme, $blog_id ); 1988 1969 } 1989 1970 … … 1999 1980 */ 2000 1981 function admin_url( $path = '', $scheme = 'admin' ) { 2001 return get_admin_url( null, $path, $scheme);1982 return get_admin_url( null, $path, $scheme ); 2002 1983 } 2003 1984 … … 2016 1997 $url = get_site_url($blog_id, 'wp-admin/', $scheme); 2017 1998 2018 if ( !empty( $path) && is_string($path) && strpos($path, '..') === false )2019 $url .= ltrim( $path, '/');2020 2021 return apply_filters( 'admin_url', $url, $path, $blog_id);1999 if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 2000 $url .= ltrim( $path, '/' ); 2001 2002 return apply_filters( 'admin_url', $url, $path, $blog_id ); 2022 2003 } 2023 2004 … … 2108 2089 * 2109 2090 * @param string $path Optional. Path relative to the site url. 2110 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.2091 * @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme(). 2111 2092 * @return string Site url link with optional path appended. 2112 2093 */ … … 2114 2095 global $current_site; 2115 2096 2116 if ( ! is_multisite() )2097 if ( ! is_multisite() ) 2117 2098 return site_url($path, $scheme); 2118 2119 $orig_scheme = $scheme;2120 if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {2121 if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )2122 $scheme = 'https';2123 elseif ( ('login' == $scheme) && ( force_ssl_admin() ) )2124 $scheme = 'https';2125 elseif ( ('admin' == $scheme) && force_ssl_admin() )2126 $scheme = 'https';2127 else2128 $scheme = ( is_ssl() ? 'https' : 'http' );2129 }2130 2099 2131 2100 if ( 'relative' == $scheme ) 2132 2101 $url = $current_site->path; 2133 2102 else 2134 $url = $scheme . '://' . $current_site->domain . $current_site->path;2135 2136 if ( ! empty($path) && is_string($path) && strpos($path, '..') === false )2137 $url .= ltrim( $path, '/');2138 2139 return apply_filters( 'network_site_url', $url, $path, $orig_scheme);2103 $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); 2104 2105 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 2106 $url .= ltrim( $path, '/' ); 2107 2108 return apply_filters( 'network_site_url', $url, $path, $scheme ); 2140 2109 } 2141 2110 … … 2157 2126 global $current_site; 2158 2127 2159 if ( ! is_multisite() )2128 if ( ! is_multisite() ) 2160 2129 return home_url($path, $scheme); 2161 2130 2162 2131 $orig_scheme = $scheme; 2163 2132 2164 if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )2165 $scheme = is_ssl() && ! is_admin() ? 'https' : 'http';2133 if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) 2134 $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; 2166 2135 2167 2136 if ( 'relative' == $scheme ) 2168 2137 $url = $current_site->path; 2169 2138 else 2170 $url = $scheme . '://' . $current_site->domain . $current_site->path;2171 2172 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )2139 $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); 2140 2141 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 2173 2142 $url .= ltrim( $path, '/' ); 2174 2143
Note: See TracChangeset
for help on using the changeset viewer.