Skip to:
Content

BuddyPress.org

Ticket #1948: 1948.patch

File 1948.patch, 2.8 KB (added by junsuijin, 17 years ago)

adds backwards compatability

  • bp-core.php

     
    605605 * eg: http://domain.com/ OR https://domain.com
    606606 *
    607607 * @package BuddyPress Core
    608  * @uses get_blog_option() WordPress function to fetch blog meta.
     608 * @uses bp_core_get_home_url() Returns the domain for the root blog with contextual SSL scheme.
    609609 * @return $domain The domain URL for the blog.
    610610 */
    611611function bp_core_get_root_domain() {
    612612        global $current_blog;
    613613
    614614        if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
    615                 $domain = get_blog_option( $current_blog->blog_id, 'siteurl' );
     615                $domain = bp_core_get_home_url( $current_blog->blog_id );
    616616        else
    617                 $domain = get_blog_option( BP_ROOT_BLOG, 'siteurl' );
     617                $domain = bp_core_get_home_url( BP_ROOT_BLOG );
    618618
    619619        return apply_filters( 'bp_core_get_root_domain', $domain );
    620620}
  • bp-core/bp-core-wpabstraction.php

     
    6161        }
    6262}
    6363
     64/**
     65 * Retrieve the home url for a given site.
     66 *
     67 * Returns the 'home' option with the appropriate protocol,  'https' if
     68 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
     69 * overridden.
     70 *
     71 * @package BuddyPress Core
     72 * @since 1.3
     73 * @adapted from @package WordPress 3.0.0
     74 *
     75 * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
     76 * @param  string $path   (optional) Path relative to the home url.
     77 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
     78 * @return string Home url link with optional path appended.
     79*/
     80function bp_core_get_home_url( $blog_id = null, $path = '', $scheme = null ) {
     81        if ( function_exists( 'get_home_url' ) )
     82                return get_home_url( $blog_id, $path, $scheme );
     83
     84        // adapted from wp-includes/link-template.php function get_home_url()
     85
     86        $orig_scheme = $scheme;
     87        $scheme      = is_ssl() && !is_admin() ? 'https' : 'http';
     88
     89        if ( empty($blog_id) || !bp_core_is_multisite() )
     90                $home = get_option('home');
     91        else {
     92                /* adapted from wp-includes/ms-blogs.php
     93                        functions get_blog_address_by_id(), get_blog_details() */
     94
     95                global $wpdb;
     96
     97                $bloginfo = $wpdb->get_row( $wpdb->prepare(
     98                        "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d", (int) $blog_id ) );
     99
     100                $home = untrailingslashit( esc_url(
     101                        'http://' . $bloginfo->domain . $bloginfo->path ) );
     102        }
     103
     104        $url = str_replace( 'http://', "$scheme://", $home );
     105
     106        if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
     107                $url .= '/' . ltrim( $path, '/' );
     108
     109        return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
     110}
     111
    64112if ( !function_exists( 'get_blogs_of_user' ) ) {
    65113        function get_blogs_of_user() {
    66114                return false;