Ticket #20759: 20759.diff
File 20759.diff, 6.4 KB (added by , 12 years ago) |
---|
-
wp-includes/link-template.php
1876 1876 * @return string Home url link with optional path appended. 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 1882 1882 /** … … 1897 1897 function get_home_url( $blog_id = null, $path = '', $scheme = null ) { 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 1903 1903 if ( empty( $blog_id ) || !is_multisite() ) { … … 1908 1908 restore_current_blog(); 1909 1909 } 1910 1910 1911 if ( 'relative' == $scheme ) 1912 $url = preg_replace( '#^.+://[^/]*#', '', $url ); 1913 elseif ( 'http' != $scheme ) 1914 $url = str_replace( 'http://', "$scheme://", $url ); 1911 $url = set_url_scheme( $url, $scheme ); 1915 1912 1916 1913 if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 1917 1914 $url .= '/' . ltrim( $path, '/' ); … … 1932 1929 * @uses get_site_url() 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 1942 1939 /** … … 1955 1952 * @return string Site url link with optional path appended. 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' ); 1973 1957 } else { … … 1976 1960 restore_current_blog(); 1977 1961 } 1978 1962 1979 if ( 'relative' == $scheme ) 1980 $url = preg_replace( '#^.+://[^/]*#', '', $url ); 1981 elseif ( 'http' != $scheme ) 1982 $url = str_replace( 'http://', "{$scheme}://", $url ); 1963 $url = set_url_scheme( $url, $scheme ); 1983 1964 1984 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )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 1990 1971 /** … … 1998 1979 * @return string Admin url link with optional path appended. 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 2004 1985 /** … … 2015 1996 function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { 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, '/');1999 if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 2000 $url .= ltrim( $path, '/' ); 2020 2001 2021 return apply_filters( 'admin_url', $url, $path, $blog_id);2002 return apply_filters( 'admin_url', $url, $path, $blog_id ); 2022 2003 } 2023 2004 2024 2005 /** … … 2107 2088 * @since 3.0.0 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 */ 2113 2094 function network_site_url( $path = '', $scheme = null ) { 2114 2095 global $current_site; 2115 2096 2116 if ( ! is_multisite() )2097 if ( ! is_multisite() ) 2117 2098 return site_url($path, $scheme); 2118 2099 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 2131 2100 if ( 'relative' == $scheme ) 2132 2101 $url = $current_site->path; 2133 2102 else 2134 $url = $scheme . '://' . $current_site->domain . $current_site->path;2103 $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); 2135 2104 2136 if ( ! empty($path) && is_string($path) && strpos($path, '..') === false )2137 $url .= ltrim( $path, '/');2105 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 2106 $url .= ltrim( $path, '/' ); 2138 2107 2139 return apply_filters( 'network_site_url', $url, $path, $orig_scheme);2108 return apply_filters( 'network_site_url', $url, $path, $scheme ); 2140 2109 } 2141 2110 2142 2111 /** … … 2156 2125 function network_home_url( $path = '', $scheme = null ) { 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;2139 $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); 2171 2140 2172 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )2141 if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 2173 2142 $url .= ltrim( $path, '/' ); 2174 2143 2175 2144 return apply_filters( 'network_home_url', $url, $path, $orig_scheme);