| 3051 | * Retrieve the blog url for a given site |
| 3052 | * |
| 3053 | * Blog url might be site root or set as a page. |
| 3054 | * |
| 3055 | * @since 4.5.0 |
| 3056 | * |
| 3057 | * @return string Blog url |
| 3058 | */ |
| 3059 | function get_blog_url( $blog_id = null ) { |
| 3060 | |
| 3061 | if ( empty( $blog_id ) || ! is_multisite() ) { |
| 3062 | $show_on_front = get_option( 'show_on_front' ); |
| 3063 | $page_for_posts = get_option( 'page_for_posts' ); |
| 3064 | |
| 3065 | if ( 'page' == $show_on_front && $page_for_posts ) { |
| 3066 | $url = get_permalink( $page_for_posts ); |
| 3067 | } else { |
| 3068 | $url = get_home_url( $blog_id ); |
| 3069 | } |
| 3070 | } else { |
| 3071 | $show_on_front = get_blog_option( $blog_id, 'show_on_front' ); |
| 3072 | $page_for_posts = get_blog_option( $blog_id, 'page_for_posts' ); |
| 3073 | |
| 3074 | if ( ! empty( $page_for_posts ) && 'page' == $show_on_front ) { |
| 3075 | $url = get_blog_permalink( $blog_id, $page_for_posts ); |
| 3076 | } else { |
| 3077 | $url = get_home_url( $blog_id ); |
| 3078 | } |
| 3079 | } |
| 3080 | |
| 3081 | /** |
| 3082 | * Filter the blog URL. |
| 3083 | * |
| 3084 | * @since 4.5.0 |
| 3085 | * |
| 3086 | * @param string $url The complete blog URL including scheme and path. |
| 3087 | * @param int|null $blog_id Blog ID, or null for the current blog. |
| 3088 | */ |
| 3089 | return apply_filters( 'get_blog_url', $url, $blog_id ); |
| 3090 | } |
| 3091 | |
| 3092 | /** |