Skip to:
Content

BuddyPress.org

Changeset 2088 for trunk/bp-core.php


Ignore:
Timestamp:
11/13/2009 01:01:37 AM (15 years ago)
Author:
apeatling
Message:

Initial support for threaded activity stream commenting. Some major performance improvements around fetching profile and group data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r2077 r2088  
    533533 * @uses get_usermeta() WordPress function to get the usermeta for a user.
    534534 */
    535 function bp_core_get_user_domain( $user_id ) {
     535function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) {
    536536    global $bp;
    537537
    538538    if ( !$user_id ) return;
    539539
    540     $ud = get_userdata($user_id);
     540    if ( $domain = wp_cache_get( 'bp_user_domain_' . $user_id, 'bp' ) )
     541        return apply_filters( 'bp_core_get_user_domain', $domain );
     542
     543    if ( !$user_nicename && !$user_login ) {
     544        $ud = get_userdata($user_id);
     545        $user_nicename = $ud->user_nicename;
     546        $user_login = $ud->user_login;
     547    }
    541548
    542549    if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    543         $username = $ud->user_login;
     550        $username = $user_login;
    544551    else
    545         $username = $ud->user_nicename;
     552        $username = $user_nicename;
    546553
    547554    /* If we are using a members slug, include it. */
    548555    if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
    549         return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' );
     556        $domain = $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/';
    550557    else
    551         return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );
     558        $domain = $bp->root_domain . '/' . $username . '/';
     559
     560    /* Cache the link */
     561    wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' );
     562
     563    return apply_filters( 'bp_core_get_user_domain', $domain );
    552564}
    553565
     
    721733}
    722734add_action( 'wp_head', 'bp_core_sort_nav_items' );
    723 
    724 /**
    725  * bp_core_remove_nav_item()
    726  *
    727  * Removes a navigation item from the main navigation array.
    728  *
    729  * @package BuddyPress Core
    730  * @param $slug The slug of the sub navigation item.
    731  */
    732 function bp_core_remove_nav_item( $slug ) {
    733     global $bp;
    734 
    735     unset( $bp->bp_nav[$slug] );
    736 }
    737735
    738736/**
     
    820818
    821819/**
    822  * bp_core_remove_subnav_item()
     820 * bp_core_remove_nav_item()
    823821 *
    824822 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
     
    828826 * @param $slug The slug of the sub navigation item.
    829827 */
     828function bp_core_remove_nav_item( $parent_id ) {
     829    global $bp;
     830
     831    /* Unset subnav items for this nav item */
     832    foreach( $bp->bp_options_nav[$parent_id] as $subnav_item ) {
     833        bp_core_remove_subnav_item( $parent_id, $subnav_item['slug'] );
     834    }
     835
     836    unset( $bp->bp_nav[$parent_id] );
     837}
     838
     839/**
     840 * bp_core_remove_subnav_item()
     841 *
     842 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
     843 *
     844 * @package BuddyPress Core
     845 * @param $parent_id The id of the parent navigation item.
     846 * @param $slug The slug of the sub navigation item.
     847 */
    830848function bp_core_remove_subnav_item( $parent_id, $slug ) {
    831849    global $bp;
    832850
     851    $function = $bp->bp_options_nav[$parent_id][$slug]['screen_function'];
     852
     853    if ( $function ) {
     854        if ( !is_object( $screen_function[0] ) )
     855            remove_action( 'wp', $screen_function, 3 );
     856        else
     857            remove_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
     858    }
     859
    833860    unset( $bp->bp_options_nav[$parent_id][$slug] );
     861
     862    if ( !count( $bp->bp_options_nav[$parent_id] ) )
     863        unset($bp->bp_options_nav[$parent_id]);
    834864}
    835865
     
    9791009    global $bp;
    9801010
    981     if ( !is_numeric($uid) )
    982         return false;
    983 
    984     return apply_filters( 'bp_core_get_userurl', bp_core_get_user_domain( $uid ) );
     1011    if ( !$url = wp_cache_get( 'bp_user_url_' . $uid, 'bp' ) ) {
     1012        $url = bp_core_get_user_domain( $uid );
     1013    }
     1014
     1015    return apply_filters( 'bp_core_get_userurl', $url );
    9851016}
    9861017
     
    9971028 */
    9981029function bp_core_get_user_email( $uid ) {
    999     $ud = get_userdata($uid);
    1000     return apply_filters( 'bp_core_get_user_email', $ud->user_email );
     1030    if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
     1031        $ud = get_userdata($uid);
     1032        $email = $ud->user_email;
     1033    }
     1034    return apply_filters( 'bp_core_get_user_email', $email );
    10011035}
    10021036
     
    10311065        return false;
    10321066
    1033     if ( function_exists('bp_fetch_user_fullname') ) {
     1067    if ( function_exists( 'bp_core_get_user_displayname' ) ) {
    10341068        $display_name = bp_core_get_user_displayname( $user_id );
    10351069
     
    10501084        return $url;
    10511085
    1052     return '<a href="' . $url . '">' . $display_name . '</a>';
     1086    return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '">' . $display_name . '</a>', $user_id );
    10531087}
    10541088
     
    16661700    global $wpdb;
    16671701    ?>
    1668 <!-- Generated in <?php timer_stop(1); ?> seconds. -->
     1702<!-- Generated in <?php timer_stop(1); ?> seconds. <?php echo get_num_queries(); ?> -->
    16691703    <?php
    16701704}
Note: See TracChangeset for help on using the changeset viewer.