| 1943 | * Output the blog url for the current site. |
| 1944 | * |
| 1945 | * Blog url might be site root or set as a page. |
| 1946 | * |
| 1947 | * @package WordPress |
| 1948 | * @since 3.4.0 |
| 1949 | * |
| 1950 | * @uses get_blog_url() |
| 1951 | */ |
| 1952 | function blog_url() { |
| 1953 | echo get_blog_url( null ); |
| 1954 | } |
| 1955 | |
| 1956 | /** |
| 1957 | * Retrieve the blog url for a given site |
| 1958 | * |
| 1959 | * Blog url might be site root or set as a page. |
| 1960 | * |
| 1961 | * @package WordPress |
| 1962 | * @since 3.4.0 |
| 1963 | * |
| 1964 | * @uses get_home_url() |
| 1965 | * @uses get_option() |
| 1966 | * @uses get_permalink() |
| 1967 | * @uses get_blog_option() |
| 1968 | * @uses get_blog_permalink() |
| 1969 | * @uses apply_filters() |
| 1970 | * |
| 1971 | * @return string Blog url |
| 1972 | */ |
| 1973 | function get_blog_url( $blog_id = null ) { |
| 1974 | |
| 1975 | if ( empty( $blog_id ) || !is_multisite() ) { |
| 1976 | $is_front = get_option( 'show_on_front' ); |
| 1977 | $page_id = get_option( 'page_for_posts' ); |
| 1978 | |
| 1979 | if ( !empty( $page_id ) && ( 'page' == $is_front ) ) { |
| 1980 | $url = get_permalink( $page_id ); |
| 1981 | } else { |
| 1982 | $url = get_home_url( $blog_id, '/' ); |
| 1983 | } |
| 1984 | } else { |
| 1985 | $is_front = get_blog_option( $blog_id, 'show_on_front' ); |
| 1986 | $page_id = get_blog_option( $blog_id, 'page_for_posts' ); |
| 1987 | |
| 1988 | if ( !empty( $page_id ) && ( 'page' == $is_front ) ) { |
| 1989 | $url = get_blog_permalink( $blog_id, $page_id ); |
| 1990 | } else { |
| 1991 | $url = get_home_url( $blog_id, '/' ); |
| 1992 | } |
| 1993 | } |
| 1994 | |
| 1995 | return apply_filters( 'get_blog_url', $url, $blog_id ); |
| 1996 | } |
| 1997 | |
| 1998 | /** |