Changeset 14702 for trunk/wp-includes/link-template.php
- Timestamp:
- 05/16/2010 09:58:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r14653 r14702 1847 1847 $orig_scheme = $scheme; 1848 1848 1849 if ( !in_array( $scheme, array('http', 'https')) )1849 if ( !in_array( $scheme, array( 'http', 'https' ) ) ) 1850 1850 $scheme = is_ssl() && !is_admin() ? 'https' : 'http'; 1851 1851 1852 if ( empty( $blog_id) || !is_multisite() )1853 $home = get_option( 'home');1852 if ( empty( $blog_id ) || !is_multisite() ) 1853 $home = get_option( 'home' ); 1854 1854 else 1855 $home = untrailingslashit(get_blogaddress_by_id($blog_id));1855 $home = get_blog_option( $blog_id, 'home' ); 1856 1856 1857 1857 $url = str_replace( 'http://', "$scheme://", $home ); … … 1900 1900 function get_site_url( $blog_id = null, $path = '', $scheme = null ) { 1901 1901 // should the list of allowed schemes be maintained elsewhere? 1902 $orig_scheme = $scheme; 1903 if ( !in_array( $scheme, array( 'http', 'https' ) ) ) { 1904 if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) ) 1905 $scheme = 'https'; 1906 elseif ( ( 'login' == $scheme ) && force_ssl_admin() ) 1907 $scheme = 'https'; 1908 elseif ( ( 'admin' == $scheme ) && force_ssl_admin() ) 1909 $scheme = 'https'; 1910 else 1911 $scheme = ( is_ssl() ? 'https' : 'http' ); 1912 } 1913 1914 if ( empty( $blog_id ) || !is_multisite() ) 1915 $url = get_option( 'siteurl' ); 1916 else 1917 $url = get_blog_option( $blog_id, 'siteurl' ); 1918 1919 $url = str_replace( 'http://', "{$scheme}://", $url ); 1920 1921 if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) 1922 $url .= '/' . ltrim( $path, '/' ); 1923 1924 return apply_filters( 'site_url', $url, $path, $orig_scheme, $blog_id ); 1925 } 1926 1927 /** 1928 * Retrieve the url to the admin area for the current site. 1929 * 1930 * @package WordPress 1931 * @since 2.6.0 1932 * 1933 * @param string $path Optional path relative to the admin url 1934 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes. 1935 * @return string Admin url link with optional path appended 1936 */ 1937 function admin_url( $path = '', $scheme = 'admin' ) { 1938 return get_admin_url(null, $path, $scheme); 1939 } 1940 1941 /** 1942 * Retrieve the url to the admin area for a given site. 1943 * 1944 * @package WordPress 1945 * @since 3.0.0 1946 * 1947 * @param int $blog_id (optional) Blog ID. Defaults to current blog. 1948 * @param string $path Optional path relative to the admin url 1949 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes. 1950 * @return string Admin url link with optional path appended 1951 */ 1952 function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { 1953 $url = get_site_url($blog_id, 'wp-admin/', $scheme); 1954 1955 if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) 1956 $url .= ltrim($path, '/'); 1957 1958 return apply_filters('admin_url', $url, $path, $blog_id); 1959 } 1960 1961 /** 1962 * Retrieve the url to the includes directory. 1963 * 1964 * @package WordPress 1965 * @since 2.6.0 1966 * 1967 * @param string $path Optional. Path relative to the includes url. 1968 * @return string Includes url link with optional path appended. 1969 */ 1970 function includes_url($path = '') { 1971 $url = site_url() . '/' . WPINC . '/'; 1972 1973 if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) 1974 $url .= ltrim($path, '/'); 1975 1976 return apply_filters('includes_url', $url, $path); 1977 } 1978 1979 /** 1980 * Retrieve the url to the content directory. 1981 * 1982 * @package WordPress 1983 * @since 2.6.0 1984 * 1985 * @param string $path Optional. Path relative to the content url. 1986 * @return string Content url link with optional path appended. 1987 */ 1988 function content_url($path = '') { 1989 $url = WP_CONTENT_URL; 1990 if ( 0 === strpos($url, 'http') && is_ssl() ) 1991 $url = str_replace( 'http://', 'https://', $url ); 1992 1993 if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) 1994 $url .= '/' . ltrim($path, '/'); 1995 1996 return apply_filters('content_url', $url, $path); 1997 } 1998 1999 /** 2000 * Retrieve the url to the plugins directory or to a specific file within that directory. 2001 * You can hardcode the plugin slug in $path or pass __FILE__ as a second argument to get the correct folder name. 2002 * 2003 * @package WordPress 2004 * @since 2.6.0 2005 * 2006 * @param string $path Optional. Path relative to the plugins url. 2007 * @param string $plugin Optional. The plugin file that you want to be relative to - i.e. pass in __FILE__ 2008 * @return string Plugins url link with optional path appended. 2009 */ 2010 function plugins_url($path = '', $plugin = '') { 2011 2012 $mu_plugin_dir = WPMU_PLUGIN_DIR; 2013 foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) { 2014 $$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs 2015 $$var = preg_replace('|/+|', '/', $$var); 2016 } 2017 2018 if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) 2019 $url = WPMU_PLUGIN_URL; 2020 else 2021 $url = WP_PLUGIN_URL; 2022 2023 if ( 0 === strpos($url, 'http') && is_ssl() ) 2024 $url = str_replace( 'http://', 'https://', $url ); 2025 2026 if ( !empty($plugin) && is_string($plugin) ) { 2027 $folder = dirname(plugin_basename($plugin)); 2028 if ( '.' != $folder ) 2029 $url .= '/' . ltrim($folder, '/'); 2030 } 2031 2032 if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) 2033 $url .= '/' . ltrim($path, '/'); 2034 2035 return apply_filters('plugins_url', $url, $path, $plugin); 2036 } 2037 2038 /** 2039 * Retrieve the site url for the current network. 2040 * 2041 * Returns the site url with the appropriate protocol, 'https' if 2042 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is 2043 * overridden. 2044 * 2045 * @package WordPress 2046 * @since 3.0.0 2047 * 2048 * @param string $path Optional. Path relative to the site url. 2049 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'. 2050 * @return string Site url link with optional path appended. 2051 */ 2052 function network_site_url( $path = '', $scheme = null ) { 2053 global $current_site; 2054 2055 if ( !is_multisite() ) 2056 return site_url($path, $scheme); 2057 1902 2058 $orig_scheme = $scheme; 1903 2059 if ( !in_array($scheme, array('http', 'https')) ) { … … 1912 2068 } 1913 2069 1914 if ( empty($blog_id) || !is_multisite() )1915 $url = get_option('siteurl');1916 else1917 $url = untrailingslashit(get_blogaddress_by_id($blog_id));1918 1919 $url = str_replace( 'http://', "{$scheme}://", $url );1920 1921 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )1922 $url .= '/' . ltrim($path, '/');1923 1924 return apply_filters('site_url', $url, $path, $orig_scheme, $blog_id);1925 }1926 1927 /**1928 * Retrieve the url to the admin area for the current site.1929 *1930 * @package WordPress1931 * @since 2.6.01932 *1933 * @param string $path Optional path relative to the admin url1934 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.1935 * @return string Admin url link with optional path appended1936 */1937 function admin_url( $path = '', $scheme = 'admin' ) {1938 return get_admin_url(null, $path, $scheme);1939 }1940 1941 /**1942 * Retrieve the url to the admin area for a given site.1943 *1944 * @package WordPress1945 * @since 3.0.01946 *1947 * @param int $blog_id (optional) Blog ID. Defaults to current blog.1948 * @param string $path Optional path relative to the admin url1949 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.1950 * @return string Admin url link with optional path appended1951 */1952 function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {1953 $url = get_site_url($blog_id, 'wp-admin/', $scheme);1954 1955 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )1956 $url .= ltrim($path, '/');1957 1958 return apply_filters('admin_url', $url, $path, $blog_id);1959 }1960 1961 /**1962 * Retrieve the url to the includes directory.1963 *1964 * @package WordPress1965 * @since 2.6.01966 *1967 * @param string $path Optional. Path relative to the includes url.1968 * @return string Includes url link with optional path appended.1969 */1970 function includes_url($path = '') {1971 $url = site_url() . '/' . WPINC . '/';1972 1973 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )1974 $url .= ltrim($path, '/');1975 1976 return apply_filters('includes_url', $url, $path);1977 }1978 1979 /**1980 * Retrieve the url to the content directory.1981 *1982 * @package WordPress1983 * @since 2.6.01984 *1985 * @param string $path Optional. Path relative to the content url.1986 * @return string Content url link with optional path appended.1987 */1988 function content_url($path = '') {1989 $url = WP_CONTENT_URL;1990 if ( 0 === strpos($url, 'http') && is_ssl() )1991 $url = str_replace( 'http://', 'https://', $url );1992 1993 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )1994 $url .= '/' . ltrim($path, '/');1995 1996 return apply_filters('content_url', $url, $path);1997 }1998 1999 /**2000 * Retrieve the url to the plugins directory or to a specific file within that directory.2001 * You can hardcode the plugin slug in $path or pass __FILE__ as a second argument to get the correct folder name.2002 *2003 * @package WordPress2004 * @since 2.6.02005 *2006 * @param string $path Optional. Path relative to the plugins url.2007 * @param string $plugin Optional. The plugin file that you want to be relative to - i.e. pass in __FILE__2008 * @return string Plugins url link with optional path appended.2009 */2010 function plugins_url($path = '', $plugin = '') {2011 2012 $mu_plugin_dir = WPMU_PLUGIN_DIR;2013 foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {2014 $$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs2015 $$var = preg_replace('|/+|', '/', $$var);2016 }2017 2018 if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) )2019 $url = WPMU_PLUGIN_URL;2020 else2021 $url = WP_PLUGIN_URL;2022 2023 if ( 0 === strpos($url, 'http') && is_ssl() )2024 $url = str_replace( 'http://', 'https://', $url );2025 2026 if ( !empty($plugin) && is_string($plugin) ) {2027 $folder = dirname(plugin_basename($plugin));2028 if ( '.' != $folder )2029 $url .= '/' . ltrim($folder, '/');2030 }2031 2032 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )2033 $url .= '/' . ltrim($path, '/');2034 2035 return apply_filters('plugins_url', $url, $path, $plugin);2036 }2037 2038 /**2039 * Retrieve the site url for the current network.2040 *2041 * Returns the site url with the appropriate protocol, 'https' if2042 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is2043 * overridden.2044 *2045 * @package WordPress2046 * @since 3.0.02047 *2048 * @param string $path Optional. Path relative to the site url.2049 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.2050 * @return string Site url link with optional path appended.2051 */2052 function network_site_url( $path = '', $scheme = null ) {2053 global $current_site;2054 2055 if ( !is_multisite() )2056 return site_url($path, $scheme);2057 2058 $orig_scheme = $scheme;2059 if ( !in_array($scheme, array('http', 'https')) ) {2060 if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )2061 $scheme = 'https';2062 elseif ( ('login' == $scheme) && ( force_ssl_admin() ) )2063 $scheme = 'https';2064 elseif ( ('admin' == $scheme) && force_ssl_admin() )2065 $scheme = 'https';2066 else2067 $scheme = ( is_ssl() ? 'https' : 'http' );2068 }2069 2070 2070 $url = 'http://' . $current_site->domain . $current_site->path; 2071 2071
Note: See TracChangeset
for help on using the changeset viewer.